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
3-Finity
Newbie


Joined: 03 Oct 2003
Posts: 5
Location: USA

PostPosted: Thu Oct 09, 2003 5:33 pm   

Callin all Geniuses!!!
 
Hey there geniuses. I need your help.

Me and a friend are currently working on a script for a mud(duh) and we need some help with some random variables using the %random function. I am trying to make a script that will walk a pre-recorded path for me using a random time number to define how often it moves. Example: n,nw,n,nw,n,nw,e,ne is the pre-recorded path. Starting at the first n , I want it to make a random time limit to use(prefferably based off of a tick timer) until it will move onto the next room which is nw. I also need the timer to stop upon a line such as "Blah blah blah enters the room". And start up again on "Blah blah blah is dead." So that it will continue timing until the next movement. if you could help us out here I would be very very grateful. Thanks in advance.
Reply with quote
Carabas
GURU


Joined: 28 Sep 2000
Posts: 434
Location: USA

PostPosted: Thu Oct 09, 2003 7:39 pm   
 
This is very basic, and is not intended to be the full solution, nor was it thoroughly tested.

Code:
#CLASS {Move}
#ALIAS mndir {#VARIABLE do_move 1
#SEND %item(@dirs,1)
#EXECUTE {%concat("#NOOP %alarm(move_alarm,",%random(500,2500),")")}}
#VARIABLE do_move {0}
#VARIABLE moving {0}
#VARIABLE dirs {n|nw|n|nw|n|nw|e|ne}
#TRIGGER {Exits} {#IF (@do_move) {#DELNITEM dirs 1}
#VARIABLE moving 0}
#TRIGGER {enters the room.} {#SUSPEND "move_alarm"}
#TRIGGER {is dead.} {#RESUME "move_alarm"}
#ALARM "move_alarm" {-10} {mndir}
#CLASS 0



A break down of the above code with explanation follows.

#ALIAS mndir: (MoveNextDIRection)

#VARIABLE do_move 1 - This variable is set to one so that upon reception of the very next Exits line, the first item of the dirs string list will be removed.
#SEND %item(@dirs,1) - This will send the first item of the dirs string list to the MUD.
#EXECUTE {%concat("#NOOP %alarm(move_alarm,",%random(500,2500),")")} - This one is a mouth full. This mess is needed to work around a possible bug that has been reported in the Beta Forum. It will set the remaining time left on the move_alarm to a random number between 500 and 2500. This number represents milliseconds and translates to one half of a second to two and a half seconds.


#TRIGGER {Exits}

#IF (@do_move) {#DELNITEM dirs 1} - If the variable @do_move is true (set to 1), then the Nth item (first) of dirs is removed from the string list. This trigger's pattern may need customization for your MUD.
#VARIABLE moving 0 - Sets the value of the moving variable to FALSE (0), incase another Exits line is received before actually moving to another room.


#TRIGGER {enters the room.}
#TRIGGER {is dead.}

#SUSPEND "move_alarm"
#RESUME "move_alarm" - Suspends and Resumes the timing of the alarm, respectively. This will in affect pause the movement script.


#ALARM "move_alarm" {-10} {mndir}

This is the alarm that will do all the moving. It is set to a default of 10 seconds of connection time. This means that if you are not connected, the script will not run. This alarm has an ID of move_alarm for reference, and it calls the mndir alias mentioned above.


It is recommended that you disable the Move class when this script is not being used. To start moving, type mndir. I trust you have other means of populating the dirs string list.

Hope this helps.
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