So, I'm writing my own curing. I think most people know this.
What I'm having trouble with, is I have a table of plant-based affs (or, ones that can be cured with plants)
Then I have another for the order I want it cured in.
But it doesn't seem to work. As in, there's times it will still cure randomly (or at least seems to)
My herb list goes like this: and my priorities go :
herbcures = { herbprios = {
<affliction> = "<cure>",.... [1] = "<aff name>",
[code]
if I can cure with plants then
for i = 1, #herbprios do
for aff, cure in pairs(herbcures) do
if table.contains(afflicted_by, aff) then
if cure ~= "" then -- some afflictions might not have cures
curing stuff, timers, echoes
return
end
end
end
end
end[/code]
Anyone know of a better way to make sure it constantly is checking the proper order? Or is the prio table set up wrong?
Just, don't be the 3000th person to say "lol get SVOF". I don't want SVOF
Comments
That said, pairs doesn't guarantee an order, and judging by your post you've got a dictionary that you almost want to treat as an ordered list. Your structure is almost certainly wrong.
Results of disembowel testing | Knight limb counter | GMCP AB files
variable = {"paralysis", "asthma", "clumsiness", etc}
Then you use ipairs to iterate over that. The moment you do variable["key"] = value you have a dictionary, and I'm not sure what would happen when trying to iterate over it.
Results of disembowel testing | Knight limb counter | GMCP AB files
if table.contains(afflicted_by,aff)
if herbcures[aff] then cure = herbcures[aff] end
if cure ~= "" then -- some afflictions might not have herb cures
-- curing stuff, timers, echoes
return
end
end
end
As mentioned above, you do want to be meticulous with how you structure your tables - either as unordered tables or ordered arrays, and use pairs() and ipairs() respectively for iteration, but at first glance the tables look fine.