|
itsmarty Novice
Joined: 29 Jan 2002 Posts: 37 Location: USA
|
Posted: Fri Feb 22, 2002 9:00 pm
Basic scripting question |
I'm having a little trouble getting started with zmud after using a mud client with limited scripting abilities for years. I'm only used to simple loops and matches so I'm trying to emulate that functionality, hoping to expand on it with zmud tricks once I get my bearings.
A short example script (with comments) from my other mud client would be
#hiding script
hide: #loop label
hide #command to hide
match hide you fail to hide #if it sees 'you fail to hide', go to loop label hide
match steal you hide #if it sees 'you hide' go to loop label steal
matchwait #wait for one of the above matches before proceeding
steal: #loop label
pause #wait for roundtime of previous command to expire
steal %1 #steal from (variable)
pause #wait for roundtime of steal command to expire
move ne
move e
goto hide #go to loop label hide
I guess my first question is one of philosophy...is it common to read scripts from files in zmud, or is nearly everything done by triggers, functions, etc? My limited success so far has been to create triggers to call my script files, which is already an improvement over having to call them up myself, but I'm curious if I'm limiting myself with this approach.
My second question is about pausing. In my mud you can't do anything else until a command roundtime expires, and I have a trigger set up to capture that roundtime in a variable. Unfortunately, telling a script file to wait isn't working for me. What I have is:
hide
#alarm + (@roundtime) {steal %1}
#alarm + (@roundtime) {move ne;move e}
hide
The problem is, the alarm doesn't stop the processing of the file, so it says 'ok, I'll wait 5 seconds to steal and 5 seconds to move, but I'll process the fourth line (hiding again) while I'm waiting'. What can I use to say 'don't read the next line until x seconds have passed'?
Thanks for any help you can offer. I've tried to give all the details I could think of, but I'll be happy to provide more if needed.
Thanks,
Martin |
|
|
|
dacheeba Adept
Joined: 29 Oct 2001 Posts: 250
|
Posted: Sat Feb 23, 2002 12:32 am |
First, it is possible to read and write from/to files with zmud.Look at functions %read and %write.
Now to the nitty gritty:
#VAR {hide_success} {} {}
#ALIAS {hide:} {hide;#IF {@hide_success=1} {steal: %1;#VAR hide_success 0}{hide: %1}
#TR {you fail to hide} {#VAR hide_success 0}
#TR {you hide} {#VAR hide_success 1}
#ALIAS {steal:} {#IF @roundtime=0}{steal from %1;#ALARM +3 {#T+ movescript}}
#ALIAS {movementcheck} {#IF {@roundtime=0} {ne;n;hide %1}
ok I just made this script of the top of my head,there probably is a better way of doing, and there could be logic flaws in there, but thats the jist of how you'd want to do something like that...If you need further explantation I'll get back to ya :) |
|
|
|
itsmarty Novice
Joined: 29 Jan 2002 Posts: 37 Location: USA
|
Posted: Sat Feb 23, 2002 2:39 am |
Thanks for responding. The problem isn't so much reading from files, though...more is it appropriate to read planned scripts from files or is it a waste of zmud's capabilities.
The mud I play (Simutronics' Dragonrealms) is heavy on repetition for skill gaining, so it's common to have scripts perform the same action or group of actions many times. Eventually you reach a point of diminished returns (checkable with the exp verb) when it's best to do something else for a while.
A common script, in pseudocode, would look like so:
prep a spell
hide; wait for roundtime to expire
hide; roundtime
cast the spell
(check experience for indication you've learned enough hiding, either move on or hide some more)
prep spell
perceive available mana; roundtime
perceive available mana; roundtime
cast
(check mana perception experience)
prep spell
forage for herbs; roundtime
forage for herbs; roundtime
cast
(check experience)
prep
focus on magical device; roundtime
focus on magical device; roundtime
cast
(check exp)
search for hidden players; roundtime
prep
juggle some balls; roundtime
cast
(check exp)
On and on for hours. This sort of thing would go on out of combat for the most part, so having triggers to stop what your doing and either fight or flee would be important...I think I saw a command to break out of a script in an emergency.
From my study of the help files and forums, it sounds like the recommended way to go about this would be an intricate web of triggers that T+ and T- each other rather than trying to step through a file. Is that your opinion as well?
Thanks,
Martin |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Sat Feb 23, 2002 3:24 am |
Alias: do_file_script
Script:
#VAR V_FileScript_ok 1
#VAR V_FileScript 0
#FILE 3 "FileScript.txt"
#NOOP Location of FileScript.Txt is in c:zmud
#NOOP The V_FileScript_Ok is your variable to stop the script
Make a panic button for you:
#BU XFS XFS {#VAR V_FileScript_ok 0}
Just add either #BU XFS 1 or #VAR V_FileScript_ok 0 to any
trigger which should stop your from spamming your file.
Alias: do_file
Script:
#ADD V_FileScript 1
#IF (@V_FileScript <= %filesize( 3)) {
%read( 3, @V_FileScript )
#ECHO FileScript @V_FileScript/%filesize( 3)
#IF @V_FileScript_ok {#ALARM +@roundtime {do_file}}
} {
#NOOP #VARIABLE V_FileScript 1;#VARIABLE V_FileScript 0 // 11:48 22Feb02
#ECHO FileScript Done
#CLOSE 3
}
You'll need something to capture the roundtime.
TonDiening
Beta Upgrading to 6.26 |
|
|
|
itsmarty Novice
Joined: 29 Jan 2002 Posts: 37 Location: USA
|
Posted: Sat Feb 23, 2002 3:37 am |
Thanks, I'll try playing around with that now and let you know how it works out. I'm capturing the roundtime with a trigger modified from something Lightbulb posted the other day:
#TR {Roundtime: (%d) secs} {#VAR Roundtime %1}}
If nothing else, learning zmud is definitely fun.
Thanks,
Martin |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Sat Feb 23, 2002 4:34 am |
I noticed that somethings don't incur a roundtime.
You could modify your script like:
Alias: do_fileScript:
#ADD V_FileScript 1
#IF (@V_FileScript <= %filesize( 3)) {
#VAR V_FileScript_Read %read( 3, @V_FileScript )
#IF (%word(@V_FileScript_Read,1) == "do") {
%copy(@V_FileScript_Read,3,%len(@V_FileScript_Read))
#IF (@V_FileScript_ok) {
#ALARM +1 {do_file}}
} {
@V_FileScript_Read
#IF @V_FileScript_ok {#ALARM +@roundtime {do_file}}
}
}
#ECHO FileScript @V_FileScript/%filesize( 3)
} {
#VARIABLE V_FileScript 0 // changed 11:48pm
#ECHO FileScript Done
#CLOSE 3
}
This will allow you to add lines to the text file with "do <command>" which
will execute immediately and not be delayed by the roundtime.
TonDiening
Beta Upgrading to 6.26 |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sat Feb 23, 2002 10:58 am |
To answer your first question, while it is possible to read scripts from files it's not common practice. For most people, the overwhelming majority of scripts are done with triggers and aliases which are loaded whenever the character is opened and remain in memory at all times.
It appears you have plenty of help with developing a delay script, so I'll leave that alone.
LightBulb
All scripts untested unless otherwise noted |
|
|
|
|
|
|
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
|
|