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
nostra
Wanderer


Joined: 23 May 2001
Posts: 68
Location: Sweden

PostPosted: Sat Sep 06, 2003 1:15 am   

How do you step through a list?
 
Hi everyone,

This is probably quite basic but I haven't been able to find the answer in the helpfile. Hopefully someone else can help me.

I want to write a trigger that execute the values in a string_list indefinitely UNTIL another trigger kicks in and turns this trigger OFF.

I guess #LOO command doesn't work since it executes ALL commands at once. So, I need a trigger that pause between each execution letting a 2nd trigger kick in and turn it off...

Any ideas? Smile
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Sep 06, 2003 4:59 am   
 
#CLASS ProbablyCloseToWhatYouWant
#VAR ListOfCommands {say fee|say fi|say fo|say fum.}
#VAR ListPos {1}
#ALARM "ListDoer" {*3} {#EXEC %item(@ListOfCommands,@ListPos);#ADD ListPos 1;#IF (@ListPos>%numitems(@ListOfCommands)) {ListPos=1}}
#TR "GiantSlayer" {You say 'fum.'} {#T- ListDoer;say He doesn't smell anything, I smote him.}
#CLASS 0
Reply with quote
nostra
Wanderer


Joined: 23 May 2001
Posts: 68
Location: Sweden

PostPosted: Sat Sep 06, 2003 5:07 pm   
 
Just one question... What does the pattern {*3} mean?

(everything is working as it should, it's just the pattern that confuses me)

[:p]
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Sep 06, 2003 5:42 pm   
 
The zMud help is a wonderful thing.
quote:

ALARM

Syntax: #ALA [id] pattern [commands] [class] [options]
Related: #TRIGGER #SUSPEND #RESUME


Allows you to set up a trigger based upon the time, rather than what is received from the MUD. The timepattern can contain a specific time, or can include wildcards as shown below. If preceded with a minus (-), the connection time is used rather than the current time.
Typically, the timepattern has the format hours:minutes:seconds, although the hours and minutes are optional. If missing, the hours or minute parameter is assumed to be an asterisk wildcard. In place of a specific numeric value, you can use an asterisk to match any value. You can also use the special wildcard *value which will match when the time MOD the value is zero. E.g. *10 matches 10, 20, 30, etc. The smallest period of time that can be matched by an alarm is half a second.

You can also define a temporary, one-time alarm by specifying a plus (+) in front of the time. The command is executed when the alarm goes off and the alarm is then deleted.
Using options with alarm type triggers is useless as they are ignored but the command syntax supports them.
When used with only id and pattern parameters it changes the pattern of the specified alarm.
Note: #ALARM does not preform any expansion on it parameters at the time of creation. If you need a parameter expanded use a syntax similar to the #EXEC example below.

ALARM examples

#ALARM -30:00 {save}
The hour isn’t specified, so it defaults to *. Thus, this trigger saves your game every 30 minutes of connect time.

#ALARM 3:00:00 {gossip "Why aren’t you sleeping?"}
This triggers at 3am local time.

#ALARM +5 {save}
Executes the "save" command in 5 seconds. This is a one-time alarm that deletes itself once it has executed.

#ALARM example {*5} {#ECHO example}
#ALARM example {+3}
Creates an alarm that will fire every 5 seconds then changes the time pattern for that alarm.

#VAR temp 5
#ALARM +@temp {@spell}
Executes the command stored in @spell in @temp seconds. This is a one-time alarm that deletes itself once it has executed. Note that @temp is not expanded in the display of the pattern but is expanded internally, so changing temp will not affect when the alarm triggers. In order to change when an alarm triggers try %alarm.

#EXEC {%concat(":Tells:#ALARM +",@temp," {#CLR}")}
A contrived example. This demonstrates how to create an alarm in another window, with a variable from this window.

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