Blademaster Limb Tracker?

Post Reply
SilverDragon
Posts: 23
Joined: Tue Mar 01, 2011 10:00 pm

Blademaster Limb Tracker?

Post by SilverDragon »

I'm trying to code a Limb Tracker and so far, it's not working. I don't know that much, and what's here has been done by a friend. any idea where this scripting goes wrong, or if it can be improved on?

Trigger:
^Whispering a prayer to the .+, you draw Dreaming Eels and unleash a slash towards (\w+)'s (.+).$

Trigger sends:
target2 = matches[2]
limbtarget = matches[3]

Trigger:
^You flourish your blade as it slices through (his|her) skin, sending blood arcing through the air.$

Trigger sends:
applylimbdamage(limbtarget, target2)


Script:

bodypartdamage={
["head"]=0,
["torso"]=0,
["right arm"]=0,
["left arm"]=0,
["right leg"]=0,
["left leg"]=0,
}

function applylimbdamage(limbtarget, target2)
if string.lower(target2) == string.lower(target) then
bodypartdamage[limbtarget] = (bodypartdamage[limbtarget] or 0) + 1
echo(bodypartdamage[limbtarget] .. "\n")
end
end

Lilija
Posts: 15
Joined: Sun Nov 28, 2010 7:13 pm

Re: Blademaster Limb Tracker?

Post by Lilija »

Just a few quick things. First, in your pregexp triggers, make sure you escape punctuation with /'s. Ie
Code: [show] | [select all] lua
^Whispering a prayer to the (.+)/, you draw Dreaming Eels and unleash a slash towards (\w+)/'s (.+)/.$
Second, matches[1] is the whole trigger line, matches[2] is going to be the first (.+), matches[3] will be (\w+), etc, etc. So you're probably going to want to make target2=matches[3] and limbtarget=matches[4].

As for your function, I believe you're using a table for bodypartdamage (hence the curly braces), in which case you'll want to use table.insert. I'm horrible with tables, so I can't be too much help there.

SilverDragon
Posts: 23
Joined: Tue Mar 01, 2011 10:00 pm

Re: Blademaster Limb Tracker?

Post by SilverDragon »

okay, I've edited the trigger line and the matches stuff, as well as adding in those forward-slashes. and yes, the limb variables are supposed to be set up as a table, though I know next to nothing about it. what do you mean by "use table.insert." ?

Daiger
Posts: 7
Joined: Sat Mar 13, 2010 8:16 pm

Re: Blademaster Limb Tracker?

Post by Daiger »

^Whispering a prayer to the .+, you draw Dreaming Eels and unleash a slash towards (\w+)\'s (.+)\.$
Try that as the trigger line, and you can test whether the trigger is working by adding an echo in it, for example echo ("Works"). The script looks right to me, at least.

eewallace
Posts: 6
Joined: Tue Feb 01, 2011 1:35 am

Re: Blademaster Limb Tracker?

Post by eewallace »

Lilija wrote:Just a few quick things. First, in your pregexp triggers, make sure you escape punctuation with /'s. Ie
Code: [show] | [select all] lua
^Whispering a prayer to the (.+)/, you draw Dreaming Eels and unleash a slash towards (\w+)/'s (.+)/.$
Second, matches[1] is the whole trigger line, matches[2] is going to be the first (.+), matches[3] will be (\w+), etc, etc. So you're probably going to want to make target2=matches[3] and limbtarget=matches[4].

As for your function, I believe you're using a table for bodypartdamage (hence the curly braces), in which case you'll want to use table.insert. I'm horrible with tables, so I can't be too much help there.
You would escape punctiation with \, not /. I don't think you need to escape ' and , though; at least I've never had to. And escaping the period at the end won't cause it to fail, it will just make it match anything for the last character, instead of just the period.
He's already got the appropriate keys in his table, so there's no need to insert them. And anyway, bodypartdamage[limbtarget]=0 would set the value appropriately, whether that key existed previously or not.

As for the original code, I would double check the trigger structure. Make trigger 2 a child of trigger 1 (drag trigger 2 onto trigger 1 in the trigger list), make sure that trigger 1 has its fire length set to 1, and that all the trigger patterns are set to perl regex type. And put in a few echos or something to figure out what's firing and what's not.

Also, you only get the "You flourish ..." line on compassslash, not legslash/armslash/centreslash, so you'll need to do something else to confirm the hit for those.

Post Reply