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


Joined: 02 Mar 2001
Posts: 5
Location: USA

PostPosted: Wed Nov 19, 2003 2:31 pm   

Help with an Expression Trigger
 
I have an expression trigger that is driving me nuts, I can't understand why it works so strangely.
What it is doing is firing anytime I open a Zmud window, or do any other Zmud action, like manually changeing the value of a compleatly unrelated variable, but will not fire when it should.
If ya'll would please take a look at this and tell me what I have done wrong I would be most thankfull. Oh, and the emphasis is on learning what I have wrong, more then correcting it.


#TRIGGER "standup" ((@standable())) {stand} "Actions|Lazy"
#COND {} {} {wait|param=1000}

What I want this to do is check @standable and if true then preform the command stand, wait 1 second then reset.

#VAR standable {%eval( @onbut() and !@waking and !@sleeping() and !@writhing and @equlib and @balance and !@stunned() and !@aeon())} {_nodef} "Actions"

The Standable variable should check each of the variables and if any of them are false (or true for the !@varname) then it should return false, but if they are all true (or false or !@varname) then it should return true. What it is returning is 0 1

Some of the variables evaluate expressions also, for example:
#VAR onbut {%ismember( onbut, @Alist)} {%ismember( onbut, @Alist)} "Actions"

Here are all the values of the variables, they should all be pretty static, since I don't have triggers to change them yet (except equilb and balance.)

onbut = 0
waking = 0
sleeping = 0
writhing = 0
equilb = 1
balance = 1
stunned = 0
aeon = 0

Thank you for taking the time to read this, and thanks in advance for any reply.

SMOG
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Nov 19, 2003 8:23 pm   
 
I'm finding it impossible to post my entire reply, but here's the first part. I'll see if I can add the rest as an additional post.

Expression triggers are checked whenever ANY variable changes, whether it's in the expression or not. If the expresssion is true, the trigger fires.
NOTE: If @var = 1, and a trigger sets it to 1, it didn't change and the trigger won't fire.

Variables which are intended for use as user-defined functions should be created with the #FUNCTION command. You used #VARIABLE, which expands the expression before storing it, to create @standable. Since the expression uses %eval, expanding it evaluates the expression and the result is what's stored to the variable. Also, you apparently created @standable before creating the variables used in its definition, which led to the multiple value.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Nov 19, 2003 9:03 pm   
 
Second part of reply, see above.

Before creating the other variables, without %eval
#VAR standable {( @onbut() and !@waking and !@sleeping() and !@writhing and @equlib and @balance and !@stunned() and !@aeon())} {_nodef} "Actions"
#SHOW @standable
Result: ( @onbut() and ! and !@sleeping() and ! and and and !@stunned() and !@aeon())
When %eval attempts to evaluate that expression it comes up with 1 0.

Since you have a fixed value for @standable, and that value is a non-null string, @standable evaluates as true and will always evaluate as true. Since your trigger expression is always true, your expression trigger fires every time any variable changes (as it should).
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Nov 19, 2003 9:07 pm   
 
Third (and final) part of reply. It appears that reply lengths have been severely restricted.

To summarize, your mistakes are:
You used #VARIABLE instead of #FUNCTION, so you got a fixed value for @standable instead of an expression.
You evaluated an expression which included undefined variables.
You used an expression trigger, but gave it what turns out to be a fixed true value.

Hope this helps you to understand better.
Reply with quote
Cuttlefish
Apprentice


Joined: 28 Oct 2003
Posts: 164

PostPosted: Thu Nov 20, 2003 7:39 pm   
 
Lightbulb: Unrelated to the question, but I was just wondering - are you using the "Quick Reply" or the full reply form? Just thinking maybe one is limited and the other isn't.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Nov 21, 2003 5:24 am   
 
I'm not certain, but I think I tried both of them with that response. I spent a couple hours trying to post it before it occurred to me to split it up. This is the only post I've had problems with, so it was probably a one-time problem.
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