Page 1 of 2

More trigger help

Posted: Sat May 07, 2011 4:03 am
by majgif
Ok, I have mostly got my triggers sorted out, but having some problems still.

First problem:

I'm trying to make a trigger so that when someone sends me a tell requesting certain spells I cast them on them. The spells are all aliased on the mud to match their respective abbreviations.

The string to trigger off is "(.*) tells you '(div|adiv|full|split|rc|cd|cp|cb)' "

The script I am trying to run is:

Send("wake")
send("" ..matches[3].. " " .. matches[2])
send("sleep")

The error I am getting says "try to call global 'send' (a nil value)" I assume that this is because the second line I am trying to send the variable that has matched.

Other things I have tried are:

send(" " ..matches[3].. " " .. matches[2])
and
send(..matches[3].. " " .. matches[2])

but I still get the same error message.

Any suggestions on how to fix this?

Thanks!

Re: More trigger help

Posted: Sat May 07, 2011 5:19 am
by Beliar
Is the "Send" in the first line capitalized in your code as well? Then thats the problem.

Re: More trigger help

Posted: Sat May 07, 2011 7:38 am
by majgif
That's exactly what it was. Thanks!!

Re: More trigger help

Posted: Tue May 10, 2011 10:07 pm
by majgif
So, onto my next problem... level gear.

I want to make a trigger to wear my levelling gear when i get low tnl.

I have the string right, but no idea how to write a script to change gear when the variable gets below a certain number, say 300.

I have gone through the manual but can't see anything in there that is similar that I can adapt. The closest is the checkHealth script, but I couldn't get that to work, there seems to be a step or 2 I am missing.

Any ideas?

Re: More trigger help

Posted: Wed May 11, 2011 11:41 am
by Akimoto
what you want to do is something like this:

if xptnl <= 300 then
send("wear items")

cant really say too much without a general idea as to what your capture method is.

Re: More trigger help

Posted: Thu May 12, 2011 8:10 pm
by majgif
i know i need to do something like that, just no idea how to make it work.

I'm triggering off my prompt, which is <(.*) (\d+)Tnl (.*)>

I tried:
if matches[3] <= 300 then
send("wear items")
end

but that doesn't work. I get an error saying it's trying to compare a string with a number.

Re: More trigger help

Posted: Thu May 12, 2011 8:39 pm
by Omni
majgif wrote:i know i need to do something like that, just no idea how to make it work.

I'm triggering off my prompt, which is <(.*) (\d+)Tnl (.*)>

I tried:
if tonumber(matches[3]) <= 300 then
send("wear items")
end

but that doesn't work. I get an error saying it's trying to compare a string with a number.
if tonumber(matches[3]) <= 300 then
send("wear items")
end

Re: More trigger help

Posted: Fri May 13, 2011 3:45 am
by majgif
that works, only problem is it spams me every time my prompt comes up until i level, what i need is something that changes gear and then maybe changes a variable to say that i am already wearing my level gear, then when i level and change back, the variable can change back so next time my tnl gets low it knows to change again.

Either that, or add another line to the trigger so that after i wear the gear it disables itself, then when i level another trigger wears my normal gear again and re-enables the first trigger.... i will check the manual to see if i can find the command to turn triggers on and off....

Re: More trigger help

Posted: Fri May 13, 2011 4:04 am
by majgif
Ok, worked it out.... that was pretty easy :D

Final trigger problem for now, I want to make a trigger so that I don't get booted for spamming the same command repeatedly. So, basically, I need a trigger that enters some random command if I enter the same command 20 times in a row.

Is this possible?

Re: More trigger help

Posted: Fri May 13, 2011 4:19 am
by Akimoto
the way I handle that is a manual override or a pause command what it does is an alias sets pause to true or false

^pause$

if system.paused then
system.paused = false
echo("System Paused")
elseif not system.paused then
system.paused = true
echo("System Unpaused
end

mine is a bit more complex but then you add this in places that would send commands like functions or certain triggers

if system.paused then return 0 end

add that to the top of the chain before any commands