I have an herb script that needs to check if I have at least two afflictions set to true before attempting a cure on certain types of afflictions.
Orginally I placed the cures in a table and then just used this...
However, on some things I don't want it to eat the herb UNLESS there is more than one affliction with that cure because I can also use a different ability to cure that affliction. If I cure with the other ability and end up eating it anyway, it strips one of my defenses. So it's okay to go ahead and eat and cure with the other ability if there are at least two afflictions that require that herb because the herb will cure one and the ability the other.
So if the cure is this herb, I don't want it to eat that herb unless there is that affliction and a second one that require that herb OR I am unable to use the other curing ability at that time. Otherwise I just do both cures at the same time and end up stripping a defense.
I changed the script to a very large set if if/elseif statements but the problem is checking for that second affliction. Do I need to make like 5 seperate functions with if/elseif checks and return true or false for each separate set? I'm not sure what the best way to do this is. I would much rather use the easy way with the table, but it doesn't work right in this case.
Orginally I placed the cures in a table and then just used this...
for _, v in ipairs(table) do
if afflicted[v.name] then
eat(v.cure)
return
end
end
However, on some things I don't want it to eat the herb UNLESS there is more than one affliction with that cure because I can also use a different ability to cure that affliction. If I cure with the other ability and end up eating it anyway, it strips one of my defenses. So it's okay to go ahead and eat and cure with the other ability if there are at least two afflictions that require that herb because the herb will cure one and the ability the other.
So if the cure is this herb, I don't want it to eat that herb unless there is that affliction and a second one that require that herb OR I am unable to use the other curing ability at that time. Otherwise I just do both cures at the same time and end up stripping a defense.
I changed the script to a very large set if if/elseif statements but the problem is checking for that second affliction. Do I need to make like 5 seperate functions with if/elseif checks and return true or false for each separate set? I'm not sure what the best way to do this is. I would much rather use the easy way with the table, but it doesn't work right in this case.