About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 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
Bobert
Beginner


Joined: 01 Apr 2004
Posts: 20
Location: Purdue University

PostPosted: Tue Nov 23, 2004 7:57 pm   

Time dependent variables
 
Is there a way to make a variable change if a conditional trigger does NOT occur within a set amount of time?

#TR {line1} {var=1}
#COND {line2} {var=0}
(great)

line2 almost always occurs within 2 seconds of line1. However when it does not, I would like to be able to assume that it did, and set var=0. Any advice on how I could do this?

#TR {line1} {var=1;#ALARM +2 {var=0}} messes up if I recieve two line1's within two seconds, because I only want var=0 after two seconds have passed from the last line1, or if line2 is recieved.

Hope this makes sense to you.
Reply with quote
a5hi5m
Beginner


Joined: 04 Mar 2004
Posts: 24
Location: Australia

PostPosted: Tue Nov 23, 2004 8:38 pm   
 
If you always want var=0 either when line2 is received, or if its not recieved within 2 seconds, for var=0 to be true anyway,

#tr {line1} {#var var2 0;#alarm 2 {#if (@var2=0) {#var var1 1;#var var2 1} {#noop}}}
#tr {line2} {#var var1 1;#var var2 1}



should work

sorry, to clarify, your orginial var i have called var1
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Wed Nov 24, 2004 12:31 am   
 
since you want the var to change wheter you get the line or not after two seconds you can use a #COND trigger with a wait state

#TRIGGER {line1} {var=1}
#COND {} {var=0} {wait|param=2000}

The first Trigger set var to 1 upon recieveing the line
The Conditonal waits 2 seconds (please note this is NOT the #WAIT command) then sets the var to 0 note the blank pattern
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Bobert
Beginner


Joined: 01 Apr 2004
Posts: 20
Location: Purdue University

PostPosted: Wed Nov 24, 2004 11:19 pm   
 
#TR {line1} {#VAR var1 1}
#COND {} {#VAR var1 0} {wait|param=2000}
#TR {line2} {#VAR var1 0}

How would this behave if I recieved two "line1" from the MUD within two seconds of each other? Would it wait two seconds after the first "line1" or after the most recently recieved match to change the variable? If "line2" is recieved before the two second wait completes it will change anyways, which is what I want.

Made up mud output:
[0:00:00]:line1 -> var1=1, waiting 2 seconds
[0:00:01]:line1 -> var1=1, waiting 2 seconds
* now, would var1=0 at [0:00:02] or [0:00:03]?

[0:00:00]:line1 -> var1=1
[0:00:01]:line2 -> var1=0
[0:00:02]: -> var1=0 (no change)
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Thu Nov 25, 2004 1:57 am   
 
Quote:
How would this behave if I recieved two "line1"

It would only fire once as the trigger is *waiting* in its second state and not the first
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Bobert
Beginner


Joined: 01 Apr 2004
Posts: 20
Location: Purdue University

PostPosted: Thu Nov 25, 2004 2:38 am   
 
nexela wrote:
It would only fire once as the trigger is *waiting* in its second state and not the first

Thanks for making that clear. Unfortunately I don't think it will work for what I'm trying to do.

I'm trying to figure out how to get it to change two seconds after the most recent line1, or if line2 is recieved. The challenge is that line1 and line2 may both reoccur within those two seconds.

#tr {line1} {#var var1 0;#var var2 0;#alarm +2 {#if (@var2=0) {#var var1 1;#var var2 1} {#noop}}}
#tr {line2} {#var var1 1;#var var2 1}

I think the above would work, except that a second occurance of line1 would start seperate #alarm, where I would prefer it to just restart the same timer. Can the Tick timer be used to solve this by possibly resetting the tick to 2 seconds at every line1, and having line2 and the Tick changing the variable?
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Thu Nov 25, 2004 3:56 am   
 
Quote:
I would prefer it to just restart the same timer


Name your alarms and they will overrite

#alarm "varAlarm" {+2} {#if (@var2=0) {#var var1 1;#var var2 1}
_________________
Zmud Support Library
Zmud Knowledge Base
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