MV Equip Weapons through script

Hi, i would like to do something like this :


$gameParty.equipItem($dataWeapons[$gameVariables.value(21)], 1);

but doesn't work, can someone help me ?
Need to know more of what your trying to do.

Is change equipment to based on a variable?
but doesn't work, can someone help me ?
equipItem is a Game_Actor function, not a Game_Party function. what youre thinking of is equipItems, which just gives you a list of the party's equips. once you have a reference to the actor, its
Code:
actor.equipItem(1, $dataWeapons[$gameVariables.value(21)])
the first argument is the slot, the 2nd is the equipment
so, if i store the actorId currently played in a variable, I can do something like :

actor.equipItem.actorX(1, $dataWeapons[$gameVariables.value(21)])
Or
actor.addSpell.actorX($dataSpells[$gameVariables.value(22)]

Actually, i'm doing a rogue like, where when you open a chest, it drop a random item on the floor or a spell, also you can only play one character, you can find other ones, but never play more than one

and you have to choose if you take it or not, and it auto equips it and leave the old one on the floor (a bit like binding of isaac).

I'm also wandering how to change the apparence of the event through script, something like in common event,

if event.Note = chest
event.Apparence = "Item" + $gameVariables.value(21)
theres a number of issues with the snippets that youve provided.

actor.equipItem.actorX(1, $dataWeapons[$gameVariables.value(21)])
  • if you put "actor" in the scriptbox, youll immediately get an error as that wont be defined. thats why i said "once you have a reference to the actor". you already stored the actor's id into a variable, so $gameActors.actor([$gameVariables.value(21)) would be your reference
  • equipItem is a function and is the function youre supposed to use.
  • equipItems doesnt return anything. its call wouldnt have any properties. what is actorX supposed to be?
  • i told you about the arguments equipItem takes, but i assumed the value of the variable an id for the weapon. Even though you didnt call it, what you did try to call would use the weapon that shares the id as the actor whose id you stored in the variable. if that isnt the case, you need to use another variable or place an id in manually
actor.addSpell.actorX($dataSpells[$gameVariables.value(22)]
same as above, but also
  • addSpell isnt a function
  • $dataSpells isnt a thing within RPGMaker MV
Where did you get these from?
  • if you put "actor" in the scriptbox, youll immediately get an error as that wont be defined. thats why i said "once you have a reference to the actor". you already stored the actor's id into a variable, so $gameActors.actor([$gameVariables.value(21)) would be your reference
  • equipItem is a function and is the function youre supposed to use.
  • equipItems doesnt return anything. its call wouldnt have any properties. what is actorX supposed to be?
  • i told you about the arguments equipItem takes, but i assumed the value of the variable an id for the weapon. Even though you didnt call it, what you did try to call would use the weapon that shares the id as the actor whose id you stored in the variable. if that isnt the case, you need to use another variable or place an id in manually
Ok , here's how i see it :

First as a common event(lets say common event 1) I store the id of the only actor in the party (let's say between 1..20) in variable no22
then secondary, when a chest is activated with the ok button, I roll a random number within 0 and 1 (variable no 23), to determine if its a weapon chest or a spell chest,
and for the third part, I roll the variable no21, so it makes a thing like this :

roll var21 1..0

if var23 = 0
roll Var21 : 1..12
giveActor(var22.value) Weapon(var21.value)

if
roll Var21 : 1..20
giveActor(var22.value) Skill(var21.value)

actor.addSpell.actorX($dataSpells[$gameVariables.value(22)]
same as above, but also
  • addSpell isnt a function
  • $dataSpells isnt a thing within RPGMaker MV
Where did you get these from?

I haven't read it anywhere, i'm just trying to explain how i see the thing, i'm kinda new to object base coding (js tho)

thanks a lot for your help
and can't find a proper documentation on internet, with all the commands and all
I haven't read it anywhere, i'm just trying to explain how i see the thing, i'm kinda new to object base coding (js tho)
i would work on getting more familiar with js first before the rest. w3schools has some js tutorials that could be helpful.

and can't find a proper documentation on internet, with all the commands and all
theres 2 documents i can suggest to you.
the script call list shows you functions grouped by their utility and shows examples of their use.

the MV Library doc has everything grouped by their class.

short of those, all of the code exists within your project inside of the js folder. once you know js and the engine well enough, its just as easy to look there
okay ^^, thank you, imma look at those, thank you a lot

Original thread: https://forums.rpgmakerweb.com/threads/equip-weapons-through-script.174474/