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


Joined: 07 Jan 2001
Posts: 12
Location: USA

PostPosted: Mon Sep 02, 2002 5:39 pm   

Help with creating a script
 
I need help creating a script that works based on timers,
not triggers. Example:
"kill monsters"
(wait 1 minute)
"bury"
"east"
"kill monsters"
(wait 1 minute)
"bury"
"west"

And say it logs out after 3 hours.

Anyone got any examples preferibly? I dont have the experience with
zmud language to create it my self. But if anyone has something
similar im pretty good at editing it. or just sample code I can use.
Anything would be most appreciated.

Thanx


Dan
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Mon Sep 02, 2002 6:06 pm   
 
You need, to use alarms. Preferably, temporary alarms.

Try reading the help entry on the #ALARM command, but basically, it would be something like this:
#ALIAS startbot {#VAR continue 1;#ALARM {+10800} {#VAR continue 0};bot}
#ALIAS bot {#IF (@continue) {kill monsters;#ALARM {+60} {bury;east;kill monsters;#ALARM {+60} {bury;west;bot}}}}

So, after you run the startbot alias, it sets a control variable to true (1) and creates a temporary alarm to have the variable set to false after 3 hours. It then calls the bot alias.

The bot alias checks to see if the control variable is true and sends "kill monsters". It then creates a temporary alarm that will go off after 1 minute. This alarm will sends "bury;east;kill monsters" and create another temporary alarm for 1 minute. This last alarm will send "bury;west" and call the bot alias again.

The whole process is repeated until @continue is false (0), which happens automatically after 3 hours or if you do it.

Kjata
Reply with quote
hierba
Beginner


Joined: 07 Jan 2001
Posts: 12
Location: USA

PostPosted: Mon Sep 02, 2002 7:35 pm   
 
Ok, Its working, and Ive been able to figure out quite a bit. But how would I edit it. so that it sends #ALARM {+60} adding a random number between 1 and 10, so sometimes its 61 seconds sometimes its 70. in syntax, I looked at help, but was not sure how to do it. Thanx

Dan
Reply with quote
hierba
Beginner


Joined: 07 Jan 2001
Posts: 12
Location: USA

PostPosted: Mon Sep 02, 2002 7:52 pm   
 
NEVERMIND!!!! :) I figured it out.

#ALARM {%random( 60, 70)}

One last thing, and Im sure its realy simple, but ive been racking my brain and cant figure it out. How do I stop it? or setup something that changes "@Continue to 0"

Dan
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Mon Sep 02, 2002 7:53 pm   
 
You may type in the command line:
continue=0

or have some script do this. It won't stop right away, but after the last alarm fires, it will.

Kjata
Reply with quote
hierba
Beginner


Joined: 07 Jan 2001
Posts: 12
Location: USA

PostPosted: Mon Sep 02, 2002 7:59 pm   
 
it did not work. i kept typing it, but nothing would happen.

Another thing.. How do I tie in a trigger to the alias. I setup a trigger so that If I die, it quits. But not sure how to tie both together.

Dan
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Tue Sep 03, 2002 12:36 am   
 
Well, if you have it set up exactly as I posted above, I see no way that doing:
continue=0

would not stop it the next time bot is called. So, after you type the "continue=0" into the command line, did you wait two minutes or so to see if it stopped? Like I said, there is no way to stop it midway, the best you can do is wait until it finishes a cycle.

On the trigger question, the trigger should do the same thing (do a "continue=0" to stop the script after the current cycle is finished).

Kjata
Reply with quote
hierba
Beginner


Joined: 07 Jan 2001
Posts: 12
Location: USA

PostPosted: Tue Sep 03, 2002 3:07 am   
 
****new problem, same script :)****
I tried resetting ALL my settings, then only having this scrip im testing to make sure nothing was interfearing. I cant figure it out. Comment below

#IF (@continue) {
equip
#wa %random(1800,2400)
unhold sword
#wa %random(1800,2400)
unhold shovel
#wa %random(1800,2400)
hold sceptre
#wa %random(1800,2400)
unwear bandana
#wa %random(1800,2400)
wear helm
#wa %random(1800,2400)
kill mystics
#ALARM {%random( 100, 120)} {
bury
#wa %random(800,1200)
north
#wa %random(800,1200)
north
#wa %random(800,1200)
kill mystics
#ALARM {%random( 90, 100)} {
bury
#wa %random(800,1200)
north
#wa %random(800,1200)
west
#wa %random(800,1200)
kill mystics

//Ok it gets here then it does its thing, like normal, how it does in every room. but all of a sudden it pops right back to begging of scrip and tries to go "north twice" I cant figure it out//

#ALARM {%random( 240, 270)} {
bury
#wa %random(800,1200)
east
#wa %random(800,1200)
east
#wa %random(800,1200)
kill mystics
#ALARM {%random( 240, 270)} {
bury
#wa %random(800,1200)
west
#wa %random(800,1200)
north
#wa %random(800,1200)
west
#wa %random(800,1200)
kill mystics
#ALARM {%random( 240, 270)} {
bury
#wa %random(800,1200)
east
#wa %random(800,1200)
north
#wa %random(800,1200)
kill mystics
#ALARM {%random( 90, 120)} {
bury
#wa %random(800,1200)
south
#wa %random(800,1200)
south
#wa %random(800,1200)
south
#wa %random(800,1200)
south
#wa %random(800,1200)
south
bot
}
}
}
}
}
}
}

Dan
Reply with quote
hierba
Beginner


Joined: 07 Jan 2001
Posts: 12
Location: USA

PostPosted: Tue Sep 03, 2002 3:49 am   
 
Hmm Ok, I discovered something, but I dont know how to fix it. It seems every time i try to run said script. It creates triggers and the triggers it creates call functions from the begging of script. I tried deleteing all "random(*,*) and putting regular numbers and it created triggers with the regular numbers. HELP! :)

Dan
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Tue Sep 03, 2002 4:06 am   
 
The #WAIT's are your problem. The way I designed my script was such that each section of code would completely finish before calling the next one. Thus, when the alias was called again at the end, the previous instance of that alias had already finished and you didn't end up with recursion.

You should really use the script as I provided it. If you need the wait time to be random, do this:
#VAR time %rand(60, 70)

and then change the time in the alarm from this:
#ALARM {+60} {commands}

to this:
#ALARM {@time} {commands}

In practice, you shouldn't ever need to use #WAIT and you should try to avoid it at all costs since it is plagued with many associated problems.

Kjata
Reply with quote
hierba
Beginner


Joined: 07 Jan 2001
Posts: 12
Location: USA

PostPosted: Thu Sep 05, 2002 12:57 am   
 
I tried what you said, and it still double looped. Or went to the begging while being in the middle. And also kept its place in script. So I deleted EVERYTHING. and used ONLY what was suggested. And it still created all this realy weird triggers. Like +10800. and a few more. So I went to basics, let me show you ...

#IF (@continue) {
equip
unhold sword
unhold shovel
hold sceptre
unwear bandana
wear helm
kill mystics
#ALARM {130} {
bury
north
north
kill mystics
#ALARM {110} {
bury
north
west
kill mystics
#ALARM {250} {
bury
east
east
kill mystics
#ALARM {250} {
bury
west
north
west
kill mystics
#ALARM {250} {
bury
east
north
kill mystics
#ALARM {110} {
bury
south
south
south
south
south
bot
}
}
}
}
}
}
}

And even after that it created triggers. I dont understand ;(... Help please, sorry im being a pain.

Dan
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Sep 05, 2002 6:54 am   
 
#ALARMs are triggers. They are a special type, but they will show up in the editor as triggers. There are three types of alarms,
a) clock time -- uses #ALA 30
b) connect time -- uses #ALA -30
c) temporary -- uses #ALA +30
Kjata used the third type, temporary, which deletes itself once it fires. You used the first type which doesn't.

For further information see the helpfile #ALARM which may be found in the table of contents by expanding the Commands book.

LightBulb
Senior Member
Reply with quote
hierba
Beginner


Joined: 07 Jan 2001
Posts: 12
Location: USA

PostPosted: Thu Sep 05, 2002 5:34 pm   
 
Thank you, it was the darn + I did not see it from the original :(. Now it works, and I feel very silly, thanx for your patience.

Sincerily

Dan
Reply with quote
Takilara
Apprentice


Joined: 31 Jan 2002
Posts: 129
Location: Norway

PostPosted: Sun Dec 15, 2002 6:35 pm   
 
I hate to ruin the fun, but remember that the mud you wanted this script for does not allow scripts Hierba.

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