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
waltv79
Newbie


Joined: 28 Aug 2010
Posts: 6

PostPosted: Sat Aug 28, 2010 6:57 pm   

Problem with #IF statement
 
I have this code which triggers no matter what on the #IF statement code follows then game output follows that.

Code:
#WAIT 4950
reel
#IF (You must regain balance) {#ECHO triggered;#WAIT 1000;reel} {#Echo returned false}

The echo's are there for debugging

Code:
Your line goes taut as a fish takes the bait and is hooked.
reel
<289/289h 270/270m 0e 0w 26x <ebpp> <b>> <LL:0 RL:0 HE:0 TO:0 LA:0 RA:0> 
You reel in your line, the fish pulling hard on the other end.
Balance Taken: 4.75s
<289/289h 270/270m 0e 0w 26x <e-pp> <b>> <LL:0 RL:0 HE:0 TO:0 LA:0 RA:0> 
The piranhas dart down the river.
<289/289h 270/270m 0e 0w 26x <e-pp> <b>> <LL:0 RL:0 HE:0 TO:0 LA:0 RA:0> 
The sky above you opens up some, leaving only partial cloud cover.
<289/289h 270/270m 0e 0w 26x <e-pp> <b>> <LL:0 RL:0 HE:0 TO:0 LA:0 RA:0> 
You have recovered balance.
<289/289h 270/270m 0e 0w 26x <ebpp> <b>> <LL:0 RL:0 HE:0 TO:0 LA:0 RA:0>  reel
triggered

You reel in your line, the fish pulling hard on the other end.
Balance Taken: 4.75s
<289/289h 270/270m 0e 0w 26x <e-pp> <b>> <LL:0 RL:0 HE:0 TO:0 LA:0 RA:0> 
You have recovered balance.
<289/289h 270/270m 0e 0w 26x <ebpp> <b>> <LL:0 RL:0 HE:0 TO:0 LA:0 RA:0>  reel

You reel in your line, the fish pulling hard on the other end.
Balance Taken: 4.75s
<289/289h 270/270m 0e 0w 26x <e-pp> <b>> <LL:0 RL:0 HE:0 TO:0 LA:0 RA:0>  reel
triggered

You must regain balance first.
<289/289h 270/270m 0e 0w 26x <e-pp> <b>> <LL:0 RL:0 HE:0 TO:0 LA:0 RA:0> 
You have recovered balance.
<289/289h 270/270m 0e 0w 26x <ebpp> <b>> <LL:0 RL:0 HE:0 TO:0 LA:0 RA:0> 
A school of piranhas swims into view.
<289/289h 270/270m 0e 0w 26x <ebpp> <b>> <LL:0 RL:0 HE:0 TO:0 LA:0 RA:0>  reel
reel
triggered

With a final tug you heave a slim cobia out of the water.
It weighs 16 pounds and 11 ounces.
Balance Taken: 4.75s
<289/289h 270/270m 0e 0w 26x <e-pp> <b>> <LL:0 RL:0 HE:0 TO:0 LA:0 RA:0> 
You must regain balance first.
<289/289h 270/270m 0e 0w 26x <e-pp> <b>> <LL:0 RL:0 HE:0 TO:0 LA:0 RA:0> 
You have recovered balance.
<289/289h 270/270m 0e 0w 26x <ebpp> <b>> <LL:0 RL:0 HE:0 TO:0 LA:0 RA:0>  reel

You are not fishing at the moment.
<289/289h 270/270m 0e 0w 26x <ebpp> <b>> <LL:0 RL:0 HE:0 TO:0 LA:0 RA:0>


Any help in why this triggers would be appreciated.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Sat Aug 28, 2010 8:23 pm   
 
The problem is your use of the #IF statement. #IF evaluates an expression, typically a comparison between two things like strings or a variable. CMUD evaluates what you have "" as a literal string, and being non-zero and non-null it will always evaluate to true.

It sounds like what you really want to do is use a #TRIGGER to match that text. You can create a temporary trigger since you don't always want that trigger or active, or you can define it and enable/disable as needed.

A little bit more advanced and likely exactly what you need (since I don't know what trigger, alias etc that code is in) is the #WAITFOR command. Something like this should do the trick.

Code:
#WAITFOR {You must regain balance} 2000 {#ECHO triggered;#WAIT 1000;reel} {#Echo returned false}


I would also caution you to be very careful with the use #WAIT since it has changed since the zMUD days. An errant #WAIT can pause the entire system for the duration of the wait, and in extreme cases cause CMUD to become unresponsive. since you just want the 'reel' command or alias sent again in a second, I would use an alarm instead. The final code would be something akin to

Code:
#WAITFOR {You must regain balance} 2000 {#ECHO triggered;#ALARM {+1} {reel} } {#Echo returned false}


Note this code is off the top of my head, so the code is untested. It should be close enough for you to get the general idea though.
_________________
Asati di tempari!
Reply with quote
waltv79
Newbie


Joined: 28 Aug 2010
Posts: 6

PostPosted: Sat Aug 28, 2010 9:16 pm   
 
Appears to be working good but murphys law is not allowing me to see exact.
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