[RMVX ACE] COUNTING VARIABLES FOR EQUIPMENT IN INVENTORY
Posts
Pages:
1
hi there, i am having some difficulty getting the right count on items that my character has, if an item is equipped it wont count that in my total. is there a way using game data to include equip item as well.
this is what it is set as: control variable (001) = (fish) in inventory
this is what i want: control variable (001) = (fish) in inventory (include equipment)
this is what it is set as: control variable (001) = (fish) in inventory
this is what i want: control variable (001) = (fish) in inventory (include equipment)
I'm pretty sure the event-command to set a variable to number of items can include inventory, so there's probably a script-way to do it. Gimme a sec...
*Edit: I was wrong. The event-command only deals with what's in inventory. Maybe I was thinking something else. Anyway, I still want to look into this out of curiosity.
*Edit2: This is what I've come up with:
*Edit3: Or, maybe not. I tried it again with multiple party members (yeah, I only had one before, so sue me), and, it's not returning the total I think it should.
*Edit4: I think this might have the highest probability of working as a general rule:
*Edit: I was wrong. The event-command only deals with what's in inventory. Maybe I was thinking something else. Anyway, I still want to look into this out of curiosity.
*Edit2: This is what I've come up with:
def equip_quantity(item) if item.instance_of?(RPG::Weapon) == true num = $game_party.item_number($data_weapons[item.id]) elsif item.instance_of?(RPG::Armor) == true num = $game_party.item_number($data_armor[item.id]) end value = 0 $game_party.members.each {|actor| actor.equips.include?(item); value+=1 } return num + value end
*Edit3: Or, maybe not. I tried it again with multiple party members (yeah, I only had one before, so sue me), and, it's not returning the total I think it should.
*Edit4: I think this might have the highest probability of working as a general rule:
def equip_quantity(item) num = $game_party.item_number(item) value = 0 i = 0 while i < $game_party.members.size actor = $game_party.members[i] j = 0 while j < actor.equips.size if actor.equips[j] == item value += 1 end j += 1 end i += 1 end return num + value end [/ruby]
The "def equip_quantity(item)" section goes into the script editor, below the "Materials" section. You should be able to use the Change Variables event-command to have a game variable equal to the value returned by the function "equip_quantity($data_weapons[1])", or what-have-you, or you can do something like...
...this, or what-have-you, via the Script event-command.
$game_variables[1] = equip_quantity($data_weapons[1]) $game_variables[2] = equip_quantity($data_armor[31])
...this, or what-have-you, via the Script event-command.
Pages:
1
















