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
Nexes
Beginner


Joined: 23 Mar 2003
Posts: 28

PostPosted: Sat May 22, 2004 7:53 pm   

Trigger Help
 
Ok, say I have an expression trigger. It runs once right, but what do I do if I want it to run again after a few seconds but I don't want it to run on every singe line that comes in from the mud? (That is I don't want to make an expression loop trigger) Its a trigger that runs if a bunch of variables are true and takes something from a string list and does it. What I want it to do is to keep doing stuff as long as there is stuff in the string list. Only...it doesn't do that. It does the first item and then stops.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun May 23, 2004 2:56 am   
 
Please stop with the vague language and give us details. What is the expression? What is the script of the trigger? What are some sample (real samples please, not blah blah this and nonsense that) commands that might be in the string?
Reply with quote
Nexes
Beginner


Joined: 23 Mar 2003
Posts: 28

PostPosted: Mon May 24, 2004 12:14 am   
 
Okies, the trigger looks like this: #TRIGGER (@arena=1 AND @curesysp=0 AND @aeon=0 AND @anorexia=0 AND @curesyspviaretardation=0 AND @herbbal=0) {#IF (!(%null( @HERBCurelist))) {
%word( %item( @HERBCurelist, 1), 2)
#wait 200
}}

I don't really understand why you need to know what the trigger actually does. My question was essentially how you would cause a trigger to run more than once but not on every single line, but whatever. As for what might be in the string it'll be a string list. It'll have elements that follow this pattern: ## eatHERBNAME. Therefore possible ones are 01 eatkelp, 02 eatbloodroot and stuff like that. The numbers are there for precedence and the second word is the alias name.
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Mon May 24, 2004 1:46 pm   
 
Using expression triggers can be tricky, since they aren't fired off of specific pattern and only when the state or the trigger or its expression changes. Putting a #WAIT command in trigger like that is undesirable, so I'd recommend the following (which should also help your trigger to fire on a timer, like you wanted):

#TRIGGER ((@arena=1 AND @curesysp=0 AND @aeon=0 AND @anorexia=0 AND @curesyspviaretardation=0 AND @herbbal=0) {#IF (!(%null(@HERBCurelist))) {%word( %item( @HERBCurelist, 1), 2)}}
#COND {} {} {wait|param=200}
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon May 24, 2004 6:29 pm   
 
I asked for details because I couldn't understand what you were asking and examples usually make questions much clearer. They also show other problems, such as the use of #WAIT which is not recommended in any trigger. #WAIT doesn't prevent the trigger from firing, it only delays its action. The Wait condition, on the other hand, actually keeps the trigger from firing during the delay because the trigger is in a different state and has a different pattern.

Expression triggers are not checked on every line. They are checked (only) when a user-defined variable changes, whether the changed variable is in the expression or not. If you receive ten lines, but no variable changes, the trigger won't be checked. If you receive one line, which changes ten variables, the trigger will be checked ten times. If you have an alarm or push a button which changes a variable, the expression will be checked without even waiting for a line. Note that a variable must CHANGE, if it's already 1 and you set it to 1 the variable hasn't changed and the trigger isn't checked.

This trigger should fire the first time when the last of its six variables changes to the required value. It will then wait at least 200 milliseconds (from the Wait condition). If none of those six variables has changed, the expression will still be true and it will then fire again when some other variable changes. That might be almost immediately, or it might not be for a long time. It would also fire again if one (or more) of the variables in the expression changed, so that the expression was no longer true, and then changed again (after the wait) so that the expression became true.
Reply with quote
Nexes
Beginner


Joined: 23 Mar 2003
Posts: 28

PostPosted: Tue May 25, 2004 3:31 am   
 
Ah! So thats why it emptied (or tried to empty) my whole string list at once...hmm, thanks for the details about how the expression trigger works LightBulb, now I'll just add a longer wait timer but I'll do it the way Larkin suggested. Thanks!
Reply with quote
Nexes
Beginner


Joined: 23 Mar 2003
Posts: 28

PostPosted: Tue May 25, 2004 3:48 am   
 
Ok, for claritiy's sake lemme ask one more question. Say I changed the trigger like this:

#TRIGGER ((@arena=1 AND @curesysp=0 AND @aeon=0 AND @anorexia=0 AND @curesyspviaretardation=0 AND @herbbal=0) {#IF (!(%null(@HERBCurelist))) {%word( %item( @HERBCurelist, 1), 2)}}
#COND {} {} {wait|param=1000}

Would I be right in saying that if the list was empty it would still do the Cond, wait 1 second and then if all the variables are still true it would run the IF statement once more and keep doing it every 1 second as long as all the variables in the expression remain true?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Tue May 25, 2004 5:19 pm   
 
No, I don't think so. The expression might be checked immediately after the CONDITION but I wouldn't expect it to be. It's not supposed to be checked until a variable changes, and the trigger won't fire until it is checked.

By the way, why do you have #IF (!(%null(@HerbCurelist)))? Wouldn't #IF (@HerbCurelist) work just as well?
Reply with quote
Nexes
Beginner


Joined: 23 Mar 2003
Posts: 28

PostPosted: Wed May 26, 2004 12:45 am   
 
Well, I didn't know that @HerbCurelist would be true if it had stuff in it. But thinking on it now I guess it should have been obvious since anything that is non zero is true. But when I made it I didn't think about it. But I guess that would work too.
Reply with quote
Nexes
Beginner


Joined: 23 Mar 2003
Posts: 28

PostPosted: Wed May 26, 2004 12:47 am   
 
Would that previous trigger work if I made it loop param? I think it would, it should do it, then do the wait, then reset to state 0 which would make it work on one line...but I can't help disliking that way of doing it. The loop param option seems wasteful and it seems to affect my other triggers.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed May 26, 2004 7:31 am   
 
Why not just make an alarm?
#ALA *1 {#IF (@arena AND !@curesysp AND !@aeon AND !@anorexia AND !@curesyspviaretardation AND !@herbbal AND @HERBCurelist) {%word( %item( @HERBCurelist, 1), 2)}}
Reply with quote
Nexes
Beginner


Joined: 23 Mar 2003
Posts: 28

PostPosted: Thu May 27, 2004 12:01 am   
 
I don't want to use an alarm because then it only runs every 1 second, what if all that is true and I can eat something but it doesn't do anything for one second? But that Alarm gave me an idea. I could add @HERBCurelist to the expression trigger and if it changes it should cause the trigger to check. The only problem is if it tries to eat something and it doesn't eat, because that would change nothing and the trigger wouldn't fire after. So may be an alarm would be a good idea. Well, thanks for the ideas!
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