My problem is a strange bug. I iterate through a hahs that have various subhashes, looking for certain keys to sum two values depending on the contents.
It works well but when i add that sum the values based on game_variables, variables),
that asignation broke the code somewhat and every time it try to add with the += to it
its like a = so at the end the values are 0 and -150, and not the sum of all.
This is the problematic code, if i comment it, it works well.
Full code:
It works well but when i add that sum the values based on game_variables, variables),
that asignation broke the code somewhat and every time it try to add with the += to it
its like a = so at the end the values are 0 and -150, and not the sum of all.
Code:
elsif key == :variables
for key, val in arr
p key, val
if val[0] == 1
v += $game_variables[key]
p 'var v', v
else
r += $game_variables[key] / 100
p 'var r', r, $game_variables[key] / 100
end
end
next
This is the problematic code, if i comment it, it works well.
Full code:
Code:
module Wep
Actions = {
:attack => {
:weapons => {
1 => [1, -150],
2 => [2, 0.50]
},
:armors => {
13 => [1, -150],
2 => [2, 0.50]
},
:shields => {
1 => [2, 0.50]
},
:actors => {
1 => [1, -150],
2 => [2, 0.50]
},
:classes => {
1 => [1, -150],
2 => [2, 0.50]
},
:variables => {
1 => [1],
2 => [2]
},
},
:general => {
:weapons => {
1 => [1, -150],
2 => [2, 1.50]
},
:armors => {
1 => [1, -150],
2 => [2, 1.50]
},
:actors => {
1 => [1, -150],
2 => [2, 1.50]
},
:classes => {
1 => [1, -150],
2 => [2, 1.50]
},
:variables => {
1 => [1],
2 => [2]
},
},
}
# 6 accions
# iteres segons el codi,sumant tot, i executant segons el subcodi, i rula be
# hiperfacil!
# fer que lo de accions usi codi dels hashes, hipersimple aleshores
# tu pases :defend i amb aixo, extreu de un hash de acciones, la bona, i ale
def self.test(action_type, actor, extra=false)
v = 0
r = 0.0
for key, arr in Actions[action_type]
#p key, arr
if key == :weapons and actor.weapon_id != 0
id = actor.weapon_id
elsif key == :shields and actor.armor1_id != 0
id = actor.armor1_id
elsif key == :variables
for key, val in arr
p key, val
if val[0] == 1
v += $game_variables[key]
p 'var v', v
else
r += $game_variables[key] / 100
p 'var r', r, $game_variables[key] / 100
end
end
next
else
next
end
#p arr, id
if arr[id] != nil
if arr[id][0] == 1
v += arr[id][1]
else
r += arr[id][1]
end
p 'c', v, r
end
end
p v, r
# comprova q r no sigui negatiu
end
end