Prompt line failure

Post Reply
BrandNew
Posts: 21
Joined: Mon Sep 14, 2009 1:23 am

Prompt line failure

Post by BrandNew »

I'm trying to create an autosipper, and I'm starting with the bare bones basic as I'm learning lua as I go.

Code: Select all

^H:(\d+) M:(\d+) E:(\d+) W:(\d+) <(\w+)(\w+)>$

echo("the trigger worked.")
health = (matches[2])
mana = (matches[3])
equilibrium = (matches[6])
balance = (matches[7])
echo("the trigger worked twice.")

if (maxhealth/3 < health) then 
send(dh)
end

if (maxmana/3 < mana) then 
echo("worked mana")
end

if balance == ("-") then 
balance = (0)
end

if equilibrium == ("-") then 
equilibrium = (0)
end
I had it so the first two echos were firing, but now none of them are and everything below "the trigger worked twice." has never worked. Not sure what I'm doing wrong (I know that nothing will actually HAPPEN as far as curing goes at this point) so any help would be great!

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Prompt line failure

Post by Heiko »

health = tonumber( matches[2] )

The same goes for all other character to number conversions. matches[n] or multimatches[n][m] are character based tables. You need to explicitly convert them into numbers as Lua cannot possibly know if you want "2" to be interpreted as a number or a string.

Have a look at the package section of this forum. There you'll find prompt balance detection, prompt extraction and autosipper scripts. If you need more help you need to export your profile - or the relevant parts of it and attach it to your postings - or at least provide screen shots of your triggers. People need to see your actual trigger settings. You can make all sorts of errors. To export your profile click on "save profile as" in the trigger editor on the top right side (a sub menu button of save profile).

Post Reply