Jump to content
Animebryan

Adding an item/weapon/armor to inventory by variable for ID

Recommended Posts

I was trying to make a common event add an item, weapon or armor to the player's inventory where the item was determined by a variable for it's database ID. By default, when adding in a item, weapon or armor, you have to specify the exact one, you can't determine it's ID by a variable.

 

Is there a script or scriptcall to work around this? Any help would be appreciated.

Edited by Animebryan

Share this post


Link to post
Share on other sites

Let's say the variable to hold the item ID is variable #5. Then all you'd have to do is a script call:

 

For an item:

$game_party.gain_item($data_items[$game_variables[5]], amount)

For a weapon:

$game_party.gain_item($data_weapons[$game_variables[5]], amount)

For armor:

$game_party.gain_item($data_armors[$game_variables[5]], amount)
Edited by Vincent

Share this post


Link to post
Share on other sites

 

Let's say the variable to hold the item ID is variable #5. Then all you'd have to do is a script call:

 

For an item:

$game_party.gain_item($data_items[$game_variables[5]], amount)

For a weapon:

$game_party.gain_item($data_weapons[$game_variables[5]], amount)

For armor:

$game_party.gain_item($data_armors[$game_variables[5]], amount)

Wow, that's really simple. Thanks for the help.

Share this post


Link to post
Share on other sites

 

Let's say the variable to hold the item ID is variable #5. Then all you'd have to do is a script call:

 

For an item:

$game_party.gain_item($data_items[$game_variables[5]], amount)

For a weapon:

$game_party.gain_item($data_weapons[$game_variables[5]], amount)

For armor:

$game_party.gain_item($data_armors[$game_variables[5]], amount)

Actually, I need to find a way to set the 'amount' to a variable as well. I have a variable called quantity to determine the amount of the item. Could I just stick another [$game_variables[x]] where it says amount?

Share this post


Link to post
Share on other sites

Yes. You would put $game_variables[6] instead of amount, assuming the amount variable is game variable #6.

Do I have to use brackets on that entire part or should I exclude them?

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×