Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
elektrisk
Novice


Joined: 06 May 2008
Posts: 38

PostPosted: Sat Nov 01, 2008 11:20 pm   

How would I..
 
Is there a way to set a trigger so that it responds to a number and any number below that number? Perhaps it's best just to show an example. I want a trigger to respond with "cast heal %1". The pattern would be:

[Test 60%]

So, how would I set it so that if Test is at 60% hp or below, it'd set off the trigger? Surely there's a way to do this, as to avoid having to make a trig for 59%, 58%, 57%, ect.

Thanks.
Reply with quote
Tarken Aurelius
Apprentice


Joined: 23 Oct 2008
Posts: 120
Location: Cincinnati, Ohio

PostPosted: Sat Nov 01, 2008 11:25 pm   
 
Try something like this:


Code:

#TRIGGER {~[Test (%d)~%~]} {#if (%1 =< 60) {cast heal %1} {}}



So an explanation, %d is the number of your percent then it checks if that number is equal to or less than 60, if so, casts heal that number, if not, does nothing.
Reply with quote
elektrisk
Novice


Joined: 06 May 2008
Posts: 38

PostPosted: Sat Nov 01, 2008 11:36 pm   
 
Tarken Aurelius wrote:
Try something like this:


Code:

#TRIGGER {~[Test (%d)~%~]} {#if (%1 =< 60) {cast heal %1} {}}



So an explanation, %d is the number of your percent then it checks if that number is equal to or less than 60, if so, casts heal that number, if not, does nothing.


Okay cool, thanks. I'm a newbie at cMUD scripting, so could you explain why there are parenthesis around %d if there aren't any around the numbers in the MUD? Also, what're the two braces, {}, at the end for? I know the very last brace closes the #if statement, but why is there a set before the closing brace?
Reply with quote
Tarken Aurelius
Apprentice


Joined: 23 Oct 2008
Posts: 120
Location: Cincinnati, Ohio

PostPosted: Sat Nov 01, 2008 11:44 pm   
 
The parenthesis allow that pattern to get stored to the %1 %2 %3 local variables for the trigger, and the second set of bracers is the 'ELSE' instructions for the IF-THEN-ELSE procedures for the #IF. Without it, CMUD might get pissy about the syntax or could cause some syntax errors if you try to add some more stuff to it since the last bracer without another opening bracket would be an unexpected syntax.
_________________
Tarken Aurelius, quality triggers since 2004! Trigger consulting since 2008! Content Developer at BatMUD (www.bat.org)
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Nov 02, 2008 12:13 am   
 
Tarken Aurelius wrote:
Without it, CMUD might get pissy about the syntax or could cause some syntax errors if you try to add some more stuff to it since the last bracer without another opening bracket would be an unexpected syntax.

Not strictly true... the else-brackets are optional if you're not using them. So #if (something) {command} and #if (something) {command} {} are functionally identical. The only time CMUD would complain is if you went to add an else-command to the end of your #if and forgot to close the brackets {} - which it'd be right to moan, since you'd have a syntax error.

On the broader topic of brackets in patterns, that means that you can have some numbers you're not interested in. For example, if your text read [Test: 40% 50%] you could use a pattern ~[Test: %d~% (%d)~%~] and that would put the second number into %1 and ignore the first, but still match as the first changed.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Tarken Aurelius
Apprentice


Joined: 23 Oct 2008
Posts: 120
Location: Cincinnati, Ohio

PostPosted: Sun Nov 02, 2008 12:21 am   
 
Yeah that's what I meant. I'm just not as good at explaining things like you Fang. :)
_________________
Tarken Aurelius, quality triggers since 2004! Trigger consulting since 2008! Content Developer at BatMUD (www.bat.org)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net