I am making a limb counter for Achaea and I have a bunch of functions but one of them I need help with. To start, it uses this table:
The function looks like this:
One of my triggers fires on "^You connect to the (.+)\.$ The (.+) could be head, torso, left leg, right leg, left arm, right arm. Since I cannot have a space between left and arm or left and leg in the table (left leg gives me an error), I need some way of combining those two words. I could do:
bodypart.wildcs[2]wildcs[2] = (bodypart.wildcs[1]wildcs[2] or 0) + 1
but that will only work if there are two wildcards in the trigger, and there isn't always. Is there anyway I could do something with gsub and then edit the table or is there an easier way to take care of this?
bodypart = {
head = 0,
torso = 0,
rightarm = 0,
leftarm = 0,
rightleg = 0,
leftleg = 0,
}The function looks like this:
function limbhit(sTrig, sLine, wildcs) -- adds damage to limbs. 1 for punch, 2 for kick
bodypart.wildcs[1] = (bodypart.wildcs[1] or 0) + 1
if GetVariable("attack") == "kick" then
bodypart.wildcs[1] = bodypart.wildcs[1] + 1
end
end -- functionOne of my triggers fires on "^You connect to the (.+)\.$ The (.+) could be head, torso, left leg, right leg, left arm, right arm. Since I cannot have a space between left and arm or left and leg in the table (left leg gives me an error), I need some way of combining those two words. I could do:
bodypart.wildcs[2]wildcs[2] = (bodypart.wildcs[1]wildcs[2] or 0) + 1
but that will only work if there are two wildcards in the trigger, and there isn't always. Is there anyway I could do something with gsub and then edit the table or is there an easier way to take care of this?