Uhm.. You first test will always hit on the first person. What you need to be doing is more complex, like:
temp = -1
tstat = ""
if ishealing == "false" then
if mhealer = "true" then
for n,g in pairs(groupArr) do
if n == maintank then
if g.here == "Y" then
if g.hits = "bad" and tstat <> "v.bad" and tstat <> "awful" and tstat <> "dying" then
temp = n
tstat = g.hits
else
if g.hits = "v.bad" and tstat <> "awful" and tstat <> "dying" then
temp = n
tstat = g.hits
else
if g.hits = "awful" and tstats <> "dying" then
temp = n
tstat = g.hits
else
if ghits = "dying" then
temp = n
tstat = g.hits
end -- if
end -- if
end -- if
end -- if
end -- if
end -- if
end -- for
if tstat <> "" then
Note ("Healing Target Found : Main " ..temp)
doheal(temp)
return ishealing
end -- if
end -- if
No idea if that code is right, BTW, but, basically. And, there is probably some way to simplify it a bit, maybe.. Instead of using strings, if it was using values, like 0, 1, 2, 3, etc. to track the condition, for example, the above could have been solved with (and is a lot less messy):
-- Some earlier point, to cast the results into easily
-- compared integers.
if hit = "bad" then
g.hits = 1
end
if hit = "v.bad" then
-- etc.
...
temp = -1
tstat = ""
...
for n,g in pairs(groupArr) do
if n == maintank then
if g.here == "Y" then
if g.hits > tstat then
temp = n
tstat = g.hits
end if
end if
...
You could still do it, with some strange Boolean math, assuming the language allowed it. And some languages let you, I think, created ordered sets, so you create a set, and then when comparing your new value against the set, it automatically knows that 'dying' is higher than 'bad', in that set, but its just easier (if you can't create such sets) to, at some earlier point, like where you receive the conditions from the mud in the first place, to convert them into integer, and work with numbers. ;)
You needed to not just testing against what ever condition there is in each pair, but also have to compare each pair. All your code was doing is looking for the first pair it could find that matched *any* criteria. |