Trying to get my health variable to do a trigger

Posted by Rivius on Mon 05 Apr 2010 02:58 PM — 4 posts, 17,573 views.

#0
Basically, I want to make a trigger than activates when my health is below a certain threshold.

This is what the prompt looks like, it is sent after each line of output.

1672h, 1128m, 1197e, 0p, 6380en, 4310w ex-


Health is the first variable.

What I did is, I made a trigger with this as the tagline

^*h, *m, *e, *p, *en, *w ex-$

And I set this as the code (lua, and I am sending to script)

health=%1
mana=%2

if health<400 then
send("Health is low! Escape)
end

But it did nothing... Can someone explain to me what I'm doing wrong?
USA #1
The problem is your use of the asterisk (*). With regex disabled, it means "match stuff here". With regex enabled, it means "0 or more of the previous character".

Here's a full trigger I made for Achaea that should hopefully work for you. I assume you're playing Lusternia or Imperian, so it will need some tweaking, but I hope it's not too hard to see how it works.

^\d+h, (?:\d+m,? )?(?:\d+e,? )?(?:\d+w,? )?c?e?x?k?d?b?(?: Vote)?-


This one is capturing nothing, just matching on any (Achaean) prompt. You can capture any of them by putting () around one of them, like (\d+)h for capturing health, or (e)?(x)? to capture your equilibrium and balance. Like so:

^(\d+)h, (?:\d+m,? )?(?:\d+e,? )?(?:\d+w,? )?c?(e)?(x)?k?d?b?(?: Vote)?-


With this setup, health is %1, equilibrium is %2, and balance is %3. Again, you'll need to make adjudments for the prompt style of your MUD. For example, to add your "p" and "en" stats:

^\d+h, (?:\d+m,? )?(?:\d+e,? )?(?:\d+p,? )?(?:\d+en,? )?(?:\d+w,? )?c?e?x?k?d?b?(?: Vote)?-


#2

try it like so mebbe?


if %1<400 then
send("Health is low! Escape)
end

K.
Australia Forum Administrator #3
Don't forget the trailing quote:


if %1 < 400 then
  Send("Health is low! Escape")
end


And Lua is case-sensitive so it is Send, not send.

And since I doubt the MUD recognizes "Health is low!" you probably mean Note, not Send.