Hello. I am trying to make a function that checks a table with "group" information and tries to cast "heal" when certain conditions are met.
This is what I have so far.
The problem is that despite my best efforts to check for priorities (tank first, then other dying people, then self, etc) the function will run through the entire series of checks on the first person in the group table and then the second and so on.
This is a result of what happens.
Member Hits Here
----------------------------
Yasmin awful Y
Is Healing? false
Heal Target Found : Dying Yasmin
Vitor v.bad Y
Is Healing? true
This is as intended, healing the awful first. However, when the members are switched in order the problem is revealed.
Member Hits Here
---------------------------
Vitor v.bad Y
Is Healing? false
Heal Target Found : Group Vitor
Yasmin awful Y
Is Healing? true
I am sure there is something simple I am missing. Any assistance would be very appreciated.
This is what I have so far.
function dohealcheck(name, line, wildcards)
maintank = GetVariable("maintank")
charname = GetVariable("chname")
ishealing = GetVariable("ishealing")
mhealer = GetVariable("mainhealer")
htarget = ""
Note ("Is Healing? "..ishealing)
if ishealing == "false" then
if mhealer = "true" then
for n,g in pairs(groupArr) do
if n == maintank then
if g.here == "Y" and g.hits == "bad" or
g.here == "Y" and g.hits == "v.bad" or
g.here == "Y" and g.hits == "awful" or
g.here == "Y" and g.hits == "dying" then
Note ("Heal Target Found : Main " ..n)
doheal(n)
return ishealing
end -- if
end -- if
end -- for
end -- if
-- Check Dying
for n,g in pairs(groupArr) do
if g.here == "Y" and g.hits == "dying" or
g.here == "Y" and g.hits == "awful" then
Note ("Heal Target Found : Dying " ..n)
doheal(n)
return ishealing
end
end
-- Check Self
if n == charname then
for n,g in pairs(groupArr) do
if g.here == "Y" and g.hits == "bad" or
g.here == "Y" and g.hits == "v.bad" then
Note ("Heal Target Found : Self " ..n)
doheal(n)
return ishealing
end
end
end
-- Check Everyone Else
for n,g in pairs(groupArr) do
if g.here == "Y" and g.hits == "v.bad" or
g.here == "Y" and g.hits == "bad" then
Note ("Heal Target Found : Group " ..n)
doheal(n)
return ishealing
end
end
end
end -- function
The problem is that despite my best efforts to check for priorities (tank first, then other dying people, then self, etc) the function will run through the entire series of checks on the first person in the group table and then the second and so on.
This is a result of what happens.
Member Hits Here
----------------------------
Yasmin awful Y
Is Healing? false
Heal Target Found : Dying Yasmin
Vitor v.bad Y
Is Healing? true
This is as intended, healing the awful first. However, when the members are switched in order the problem is revealed.
Member Hits Here
---------------------------
Vitor v.bad Y
Is Healing? false
Heal Target Found : Group Vitor
Yasmin awful Y
Is Healing? true
I am sure there is something simple I am missing. Any assistance would be very appreciated.