|
Necro Beginner
Joined: 22 Mar 2003 Posts: 10 Location: USA
|
Posted: Sat Mar 22, 2003 9:54 pm
Help learning ZMud script writing. |
I played DR for about 8 years. Using Wizard front end, I wrote hundreds of scripts. Far less to comprehend than with Zmud. I have made a few buttons that highlight character names by race and can highlight names. I've printed and read the manual for ZMud many times but find myself totally frustrated trying to write scripts.
I am playing Inferno. I have no desire to be afk, I just hate having to repeat mundane commands.
For example, I want to make a piece of armor or carve a bow while I am talking to someone. If I were using the Wizard, I would just make a script that listed the command I wanted to be doing then wait 1 to allow it to wait for the round time to be over then type the next command I wanted to do. ie.
Craft longbow with wood
pause 1
craft carved with druidic runes into wood
pause 1
craft wood for Necro
pause 1
work wood
pause 1
waitfor finish carving your longbow
pause 1
alter longbow with polished
I know that's simple compared to ZMud scripts, but I could use some help understanding how to write that with varables to automate it. I want to wait for the RT to finish before each next command is sent to the Mud and I want it to keep "Work Wood" until I receive the message, "finish carving your longbow" Then go on to the next command.
Anyone care to shed some light on this novice Zmud brain? Or even better.. a tutor
Necro - Never lost, always confused. |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sun Mar 23, 2003 12:28 pm |
You could use #WAIT to emulate the functionality of "pause". However, since #WAIT could cause some undesired side-effects, I'm not going to be discussing that method here. What I'm going to provide you is with a queue system that will execute a set of commands while waiting a pre-defined amount of time between each command:
#VAR queueWait {1}
#ALARM "queueAlarm" {*@queueWait} {#IF (@index <= %numitems(@queue)) {#EXEC {%item(@queue, @index)};#ADD index 1} {#T- queueAlarm}} "" {disable}
#ALIAS doCommands {#VAR queueWait {%1};#VAR queue {%-2};#VAR index 1;#T+ queueAlarm}
To use it you call the doCommands alias (you can rename it to whatever you want), with two arguments: the amount of seconds to wait between each command and a strignlist (a list fo values separated by |'s) that contains the commands to be executed (you can either type in the stringlist yourself or supply a variable containing the stringlist). Examples:
doCommands 1 get steak bag|eat|sleep
#VAR myList {get steak bag|eat|sleep}
doCommands 1 @myList
If you want to know how the queue works, the explanation is at the end. Now, to fully implement what you want to do, you could use this queue system along with some triggers. In your case, you need to wait for the "finish carving your longbow" message to appear before continuing. This means that you need a trigger for this message that will continue the commands. To make all of this simpler, we'll put all of the commands in an alias:
#VAR bowCommands1 {Craft longbow with wood|craft carved with druidic runes into wood|craft wood for Necro|work wood}
#VAR bowCommands2 {alter longbow with polished}
#ALIAS carveBow {doCommands 1 @bowCommands1;#TEMP {finish carving your longbow} {doCommands 1 @bowCommands2}}
So now all you would have to do is call the carveBow alias. What the alias will is call the queue system with the first part of the commands (up until the "work wood" command), then it creates a temporary trigger (a trigger that deletes itself once it fires) to look for the "finish carving your longbow" message. When the trigger sees this message, it calls the queue system again but this time it sends the second part of the commands.
Now, here's how the queue system works in case you want to know. The alias doCommands sets the variables to their appropiate values when called. It sets the time to wait between each command in @queueWait, the commands to execute in @queue and sets the variable @index to 1. @index is the variable that stores in which we command we are currently in the queue (first, second, etc.). After setting the variables it then enables the alarm.
The alarm is set to fire whenever @queueWait seconds have passed. Whenever this happens, the alarm fires and proceeds to check if @index is bigger than the amount of items in the @queue stringlist. If it is, then we have reached the end of the queue and the alarm disables itself. If it isn't then it uses the %item function to return the next item in the @queue stringlist (the one pointed to by @index) and sends this to the #EXEC command. The #EXEC commands executes this just as if you had typed it in yourself. Finally, after executing the command, we add 1 to @index (so it points to the next command in the queue) using the #ADD command.
Kjata |
|
|
|
Necro Beginner
Joined: 22 Mar 2003 Posts: 10 Location: USA
|
Posted: Mon Mar 24, 2003 12:20 am |
Thank you very much Kjata. That gives me quite a bit more understanding of how to go about this. I can use the same type of queue system for other craft skills as well. I have one character that makes bows and leather armor and one that carves other things. At the moment it takes hours to make one item when I could be doing other things that don't add round time and not have to concentrate so hard on the crafting.
I will test it out tonight. Oh and I read a post about #wait and it's misuse. Thank you much. I will get busy on it right now.
Necro - Never lost, always confused. |
|
|
|
Necro Beginner
Joined: 22 Mar 2003 Posts: 10 Location: USA
|
Posted: Mon Mar 24, 2003 5:54 am |
I tried to make a script from this queue system to carve a box from a piece of wood in Inferno. I am not sure how far off I am but here is what I used:
------------
#VAR queueWait {1}
#ALARM "queueAlarm" {*@queueWait} {#IF (@index <= %numitems(@queue)) {#EXEC {%item(@queue, @index)};#ADD index 1} {#T- queueAlarm}} "" {disable}
#ALIAS boxCommands {#VAR queueWait {%1};#VAR queue {%-2};#VAR index 1;#T+ queueAlarm}
#VAR boxCommands1 {wield mallet with chisel|craft box into wood|carve carved with overlapping pentagons into wood|carve wood with heavy}
#VAR boxCommands2 {carve wood with medium}
#VAR boxCommands3 {carve wood with gentle}
#VAR boxCommands4 {get box|alter box with polished|unwield}
#ALIAS boxCommands {boxCommands 1 @boxCommands1;#TEMP {a little more than halfway done.} {boxCommands 1 @boxCommands2} boxCommands 2 @boxCommands2;#TEMP {light at the end of the tunnel.} {boxCommands 2 @boxCommands3}boxCommands 3 @boxCommands31;#TEMP {With a final strike of a sculpting chisel you finish} {boxCommands 3 @boxCommands4}}
---------
This is the error message zMud gave me:
Infinite loop detected in command parsing.
Could you shed some light on my errors?
This is what I intended the script to do.. here is a list of the commands as they should have been entered:
-Craft box into wood
-carve carved with overlapping pentagons into wood
-carve wood with heavy
<This is where I need to repeat the command after each roundtime is over Until I see "a little more than halfway done.">
<Then>
-carve wood with medium
<Until I see "light at the end of the tunnel">
<Then>
-carve wood with gentle
<Until I see "With a final strike of a scuplting chisel you finish">
<Then>
-get box <since it appears on the ground>
-alter box with polished
-unwield
I'm trying to get a grasp on it. Really I am.
Necro - Never lost, always confused. |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Tue Mar 25, 2003 4:03 pm |
First, there is no need to recreate the queue system, once you have it, all you need to do is use it. Also, you need to understand clearly how to use it, it seems you have a bit of confusion. You will always call it like this:
doCommands seconds commands
where seconds is the time to wait between each command, and commands is a stringlist (preferably contained in a variable) that has the commands to execute.
Next, you must realize that the part about sending a command over and over until a message is repeated is not currently possible with what you already have. We need to devise another method for this. A solution would be to create an alias that checks to see if we have finished, and if it has not it sends the command and then creates a temporary alarm that calls the alias again. Example:
#ALIAS carveheavy {#IF (!@finished) {carve wood with heavy;#ALARM {+1} {carveheavy}}}
This alias first checks to see if the @finished variable is false. If it is, then we send the command again and create a temporary alarm (the +1 means it will fire in one second and will delete itself once it fires) to call the alias again. You could then have two other aliases for the other two commands:
#ALIAS carvemedium {#IF (!@finished) {carve wood with medium;#ALARM {+1} {carvemedium}}}
#ALIAS carvegentle {#IF (!@finished) {carve wood with gentle;#ALARM {+1} {carvegentle}}}
As you can see the three of them are the same and the only thing that changes is a word in each one. This means that we can make only one which works for all three cases. This alias replaces the other three:
#ALIAS autoCarve {#IF (!@finished) {carve wood with %1;#ALARM {+1} {autoCarve %1}}}
This alias does the same as any of the first three, but now you must tell the alias how you want to carve. Examples:
autoCarve heavy
autoCarve medium
autoCarve gentle
We now have the repeating part, but we still need a way to stop the alias once it starts repeating. To do this, we can again use temporary triggers. Example:
#VAR finished 0;#TEMP {a little more than halfway done.} {#VAR finished 1};autoCarve heavy
Notice how we reset the @finished variable before calling autoCarve. Then we create a temporary trigger that sets @finished to true once it fires.
Putting it all together, here is how the alias for carving a box would look (read it very carefully and try to understand it because it gets a bit complicated at the end since we must use nested temporary triggers):
#VAR boxCommands1 {wield mallet with chisel|craft box into wood|carve carved with overlapping pentagons into wood|autoCarve heavy}
#VAR boxCommands2 {get box|alter box with polished|unwield}
#ALIAS carveBox {doCommands 1 @boxCommands1;#VAR finished 0;#TEMP {a little more than halfway done.} {#VAR finished 1;#ALARM {+2} {#VAR finished 0;#TEMP {light at the end of the tunnel} {#VAR finished 1;#ALARM {+2} {#VAR finished 0;#TEMP {With a final strike of a sculpting chisel you finish} {#VAR finished 1;doCommands 1 @boxCommands2};autoCarve gentle}};autoCarve medium}}}
The temporary alarms of 2 seconds are used to allow the autoCarve alias time to finish. Also, notice how @boxCommands1 has the call to the alias autoCarve with the argument of "heavy". This shows that the variables may also contain call to aliases or other zMUD commands.
Kjata |
|
|
|
Necro Beginner
Joined: 22 Mar 2003 Posts: 10 Location: USA
|
Posted: Tue Mar 25, 2003 11:19 pm |
Thanks Kjata. I will give it another go. I can see I'm going to have to play with the workings of Aliases and Variables until a lightbulb comes on in my head. You have been a great help to me, I appreciate it.
Necro - Never lost, always confused. |
|
|
|
miles2go Beginner
Joined: 27 Jul 2001 Posts: 20
|
Posted: Wed Jul 30, 2003 2:20 pm |
Necro, try counting the number of blows it takes in carving in Inferno. I may be wrong but I believe it always takes 10 blows heavy, 10 blows medium and 10 blows light to finish a carving. This could make your script a lot easier to write.
I also use an entirely different system based on using the tick timer rather than temporary alarm variables. I use it mostly for hunting now, but once upon a time I had it working for crafting. |
|
|
|
|
|
|
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
|
|