RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
RMXP Add Item by ID determined by Variable

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 89
I have attention problems.
I'm trying to add a little cheat system in a game I'm making.  What I'm having trouble with at the moment is an event that lets me add an item to the inventory by ID.  So far I've got an event that sets variable id 0152 with button input processing, then I was going to use a script to add the specified item.  I'm not so good at scripting so I just guessed this by looking at other scripts...
$game_party.gain_item ($game_variable[152], 1)
Anyone know what I'd have to change to make this work?  It works if I specify an item id, but how can I make it work to use the variable as the item id?
"...because, you know, whatever."

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Code: [Select]
var = $game_variables[152]
$game_party.gain_item(var, 1)

Should work. Just put it in a call script. Also, remember that it's $game_party.gain_weapon for weapons and $game_party.gain_armor for armours.

***
Rep:
Level 89
I have attention problems.
Copied that letter for letter, tried it with item id 001, gave an error message "NoMethodError occurred while running script.  undefined method '[]' for nil:NilClass"
 :(
"...because, you know, whatever."

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
That's weird. Did you remember to put an s after $game_variable? So it was $game_variables?
Otherwise, it might be something wrong with your RPG Maker XP.

***
Rep:
Level 89
I have attention problems.
No, of course I didn't remember to put the s.  -.-

Thanks a lot for the help, it's working now!  You saved me from having to make a conditional branch for every single item...  heh.
"...because, you know, whatever."