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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Dodgester
Wanderer


Joined: 17 Nov 2005
Posts: 65

PostPosted: Sun Nov 27, 2005 11:27 pm   

#if function acting different from expected
 
The following is in the trigger for when the output of the mud returns:

You lost your concentration.

It's supppose to check for what was the last command issued. However, it appears that it always returns true for the second "#if" regardless if the first "#if" is true or false. It's not suppose to be nested, but it is suppose to be 2 separate if, then, as there is no else in either of the "#if" commands. Obviously, given how variables works, I also have to be aware that those variables could be changed, if other triggers has use of the same variable name, so that has to be safeguarded against, but that's not the issue in this case. However, with that said, it would be nice to have scope level variables similar to how it's done in either C## or VB (Block [.NET only], Procedure, Module [Class or Standard], File [Assembly/Project], or Global)

Code:
#var LastStateCommand %lastcom
#var LenLastCommand %len( @LastStateCommand)
#if (@LastStateCommand = "c 'create food'") {c 'create food'}
#if (@LastStateCommand = "c 'create water' " @drnkcont) {c 'create water' @drnkcont}


Sincerely,

Dodgester
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Sun Nov 27, 2005 11:38 pm   
 
It is very likely that implicit concatenation is causing the problem. Switch to explicit concatenation and everything should be fine.
#if (@LastStateCommand = %concat("c 'create water' ",@drnkcont)) {c 'create water' @drnkcont}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Dodgester
Wanderer


Joined: 17 Nov 2005
Posts: 65

PostPosted: Sat Dec 17, 2005 7:41 pm   
 
Thank you for the advice. Sorry for the delay. This was of help.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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