Easy, Script call for storing equipment ID in variables.

Hi all!! I cant get this right. I know that equipment has a slot allocated to them. (slot 0 for weapon, 1 for armor, etc etc) So I want to check all equipment of actor X and store each weapon and armor Id´s it has currently equipped on variables.

Ive tried something like this:
Code:
$gameVariables.setValue(X, $gameActors.actor(X).equips()[X].id);

To no avail.

Thanks for the help!!
Code:
$gameActors._data.forEach(function (actor, index) {
    "use strict";

    var equipment = {
        weaponIds: [],
        armorIds: []
    };

    actor.weapons().forEach(function (weapon) {
        equipment.weaponIds.push(weapon.id);
    });

    actor.armors().forEach(function (armor) {
        equipment.armorIds.push(armor.id);
    });

    $gameVariables.setValue(index, equipment);
});
Was a bit confused with the code but after a bit of research, I got it...thank you!!!

Original thread: https://forums.rpgmakerweb.com/threads/easy-script-call-for-storing-equipment-id-in-variables.89017/