Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

I need to make a variable equal to equipment amount

I really need one of my variables to be equal to the amount of my equipment (i.e.: if my hero is holding 99 Bronze Swords, my variable should be equal to 99). The only problem is in the Variable Operations screen, I can only set it to the amount of items, not the amount of equipment. I wasn't sure if there was a way to do it without scripting or not, so I posted here. But if scripting is a solution, that's fine.
 
1st, better i.e.: (if my hero is holding 5 swords, 2 shields & 3 rings, my variable should be equal to 10)

Assuming that's true, you need 2 script event commands:
(one to count weapons, one to count armor)
(split in 2 because it won't all go in 1 command window)

Code:
#initialize variable 10 to zero
$game_variables[10] = 0
# count weapons
for i in 1...$data_weapons.size
  if $game_party.weapon_number(i) > 0
    $game_variables[10] += $game_party.weapon_number(i)
  end
end

Code:
# count armors
for i in 1...$data_armors.size
  if $game_party.armor_number(i) > 0
    $game_variables[10] += $game_party.armor_number(i)
  end
end

This sets variable 10 to the total number of equipment items in inventory.

(yes, I pretty much swiped this from the Window_EquipItem script) :)

Be Well
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top