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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
NeverNor
Novice


Joined: 18 Nov 2006
Posts: 32

PostPosted: Fri May 18, 2007 7:00 pm   

Another syntax question
 
How do I use AND and OR in an #IF statement? I can't seem to get the syntax right.

Oh and that little button in Settings for variables that says "Reset to Default" How do I get a script to execute that function?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri May 18, 2007 8:46 pm   
 
Your problem possibly stems from each side of the AND or OR having to be a complete expression in itself

@AutoHeal = 1 OR 2

Means "If @Autoheal=1 is true or if 2 is true" and not "If @Autoheal is 1 or if @Autoheal is 2". All you need do then is use the expression, in brackets, as the first parameter of the #if command:

#if (@AutoHeal=1 OR @Autoheal=2) {true-command} {false-command}

The word doesn't need to be capitalised.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
NeverNor
Novice


Joined: 18 Nov 2006
Posts: 32

PostPosted: Sat May 19, 2007 6:00 am   
 
Ok thanks; does anyone know anything about the "Reset to Default" button being activated from script? Or whatever function you can use to reset a single variable to its default?
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Sat May 19, 2007 6:24 am   
 
hmm this is how I would do it.
to reset a variable named laser in the default class
Code:
#var laser %session.GetVar("laser","").Default
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat May 19, 2007 6:36 am   
 
I've seen people try using #RESET Variable. No idea if that works on specific settings, though.
_________________
EDIT: I didn't like my old signature
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat May 19, 2007 1:18 pm   
 
It doesn't, hence the crazy COM scripting that Dharkael has going on there. It's a feature I often dream wistfully about during my more introspective hours.

Does this script work in CMUD? I can't get it to work, it results in @laser containing the words "laser.Default".
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Sat May 19, 2007 6:44 pm   
 
Confirmed results for CMUD. Copying topic to CMUD BETA Forum.
_________________
Taz :)
Reply with quote
NeverNor
Novice


Joined: 18 Nov 2006
Posts: 32

PostPosted: Sun May 20, 2007 2:07 am   
 
Thanks for your input
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Mon May 21, 2007 1:35 am   Function to reset specific variable to default value
 
Here is a more general solution for doing this in zMud
Code:
#FUNC ResetVar {#call %comset(%comget(%session,"GetVar","%1","%2"),"Value",%session.GetVar("%1","%2").Default)}


to reset a variable named maser:
#exec @ResetVar(maser)
that will reset maser in the default class.
to reset maser in a class called subclass do this:
#exec @ResetVar(maser,subclass)

hopefully this is what both NeverNor and Fang Xianfu had been dreaming about.
I'm sure some CMUDder can translate this to that Client Wink
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon May 21, 2007 1:39 am   
 
It'd be simple enough - just removing the quotes around the %n variables should do it, but %session.GetVar().Default isn't working at the moment :(

Also, should this really be used with #exec since it's not a command? #call seems more appropriate.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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