|
NeverNor Novice
Joined: 18 Nov 2006 Posts: 32
|
Posted: 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? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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. |
|
|
|
NeverNor Novice
Joined: 18 Nov 2006 Posts: 32
|
Posted: 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?
|
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: 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." |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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". |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Sat May 19, 2007 6:44 pm |
Confirmed results for CMUD. Copying topic to CMUD BETA Forum.
|
|
_________________ Taz :) |
|
|
|
NeverNor Novice
Joined: 18 Nov 2006 Posts: 32
|
Posted: Sun May 20, 2007 2:07 am |
Thanks for your input
|
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: 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 |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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. |
|
|
|
|
|