Is there a way to reference an item by the item index number in an event?

Status
Not open for further replies.

Celestrium

Worldsmith
Veteran
Joined
Mar 3, 2020
Messages
260
Reaction score
293
First Language
English
Primarily Uses
RMMZ
I am trying to do an event where I store a number in a variable and then use that to retrieve the type of item. I am then using that to give that particular item to the party. Is there a way to do this?
 

Aerosys

Veteran
Veteran
Joined
Apr 23, 2019
Messages
534
Reaction score
510
First Language
german
Primarily Uses
RMMZ
Here you go!

Code:
const itemId = $gameVariables.value(YOUR_VARIABLE_ID);
$gameParty.gainItem($dataItems[itemId], 1)

Replace YOUR_VARIABLE_ID with your variable Id. Additionally, you can replace 1 with any other number to give more items to the Party.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
8,395
Reaction score
5,546
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Profile Posts

my main character isn't the warrior of light or the chosen one, he's a self righteous, invasive try hard who gets ahead of himself and makes a critical error, resulting in a downward moral spiral that, eventually, leads him to truths that make him a better man, and im DAMN proud of that.
Generate Actors, Dark Fantasy Monsters, & I Heard There Was a Chosen One, | RPG Maker News #42

Work on Cat Quest: The Last Catmancer continues slowly but surely. :kaopride: Today I received the Game Over screen from @Finnuval!
GameOver.png
Hey everyone! No Studio Blue RPG Maker Critiques Stream today! But you can always check the playlist for old streams you've missed!

Forum statistics

Threads
111,445
Messages
1,061,150
Members
144,806
Latest member
HowlingMeteor277
Top