Small If statement help

Posted by Sparafucile on Fri 09 Dec 2005 06:37 PM — 10 posts, 36,723 views.

#0
Hey, small question. I want to make a trigger that reads a number off in my prompt and compares it to another number, and then performs a command accordingly. ie,

If "hp" < 1000 then
(do some command)
end if

I tried putting <*hp *mp *mv *Exp to Level> (my prompt) in the trigger box, and this in the send box:

If %1 < 1000 then
(some command)
End if.

Didn't work, evidently. Thanks in advance!
USA #1
Make sure that the trigger is correct and is matching on the prompt. If it is, then using %1 should work. Unless HP is formatted with commas?
Australia Forum Administrator #2
That should work. Can you copy the actual trigger rather than retyping? End If does not have a period after it, for instance.

Can you give the error message? "Didn't work" doesn't tell us much.
#3
Alright, basically, this is the trigger I did (copied and pasted as it appears in the trigger):

Trigger box: <*hp *mp *mv *Exp to Level>

Send box:

if %1 < 1000 then
tell sparafucile Your alt is dying!
End If

I basically coppied my prompt exactly as it appears in the mud, except I replaced the numbers with *. I tried checking the Regular Expression on and off, but neither worked. And there's no error message: it just does nothing.

I know its a pretty silly trigger, since it'll just keep spamming me with tells from myself, but I don't want the alt dying :P
USA #4
You need to change the "send to" dropdown menu to script.

and then your second line needs to be:
send "tell sparafucile Your alt is dying!"

You can also copy WHOLE triggers, from the triggers dialog (the one with the list of all triggers) highlight the trigger and click 'copy' then paste the text here.
#5
Oh cool. Ok, so I copied it and this is what I have now, after changing it to script and that jazz. Still didn't work.


<triggers>
  <trigger
   enabled="y"
   match="&lt;*hp *mp *mv *Exp to Level&gt;"
   send_to="12"
   sequence="100"
  >
  <send>If %1 &lt; 6000 then
send "tell sparafucile Urwendi is dying!"
End If</send>
  </trigger>
</triggers>
Amended on Sun 11 Dec 2005 07:32 AM by Nick Gammon
Australia Forum Administrator #6
OK, now can you post some example output? What the MUD sends you? I presume you have scripting turned on?
Amended on Sun 11 Dec 2005 07:33 AM by Nick Gammon
#7
If you mean the enable script checkbox in the Scripting>Scripts window, then yes, it's checked on. The scripting language is set to VBscript, if that helps.

Here's a sample output:

[Obvious Exits: north east northeast (southwest)]
A Wooden Bench sits at the edge of the Plaza.

<5000hp 50mp 498mv 586Exp to Level>

Again, MUSH gives me no error messages or anything, it just keeps going as if the trigger did not exist.
Amended on Sun 11 Dec 2005 09:35 PM by Sparafucile
Australia Forum Administrator #8
That output works for me. Look carefully to make sure there isn't something after the > symbol, such as a space.

Triggers are rather literal, they have to match exactly.

You could try matching on:

<*hp *mp *mv *Exp to Level>*

That extra asterisk will catch any other stuff at the end of the line.
#9
Haha, that's so strange. That did it. There was indeed a space at the end of the prompt. I also had to uncheck the regular expression box. Thanks everyone :)