|
dracx Beginner
Joined: 14 Oct 2000 Posts: 26 Location: USA
|
Posted: Sat Mar 09, 2002 8:15 am
Alias Help (long post) |
My mud only has so many type-ahead lines allowed. Often, what this means is that if I'm playing while I'm running a script, I will often get an error from the game stating that I have only 2 type-ahead lines, and those commands are discarded, so I am working on a way to only send scripted commands to the game on a prompt, instead of just sending them as my code happens across them. The code I've written is posted at the bottom of this message.
The goal of this bit of code is this:
My mud has an empty prompt (">", which means there's nothing special about my status) and a string prompt ("HR>", this would mean that I am hiding, and that I am in a roundtime, which limits the commands I can perform).
When I script a command, instead of typing "LOOK", I want to be able to type "/DO LOOK", which should place that command in a list called @commands. When I receive a prompt, either empty or one that DOES NOT contain the letter "R", it send the first command in the list, and then delete that command from the list. The next command would get sent at the next qualifying prompt.
It has been working as desired, except for one thing. I want it to be able to handle more than one word commands. If I use "/do look", that works great. However, sometimes I might want to
"/do put my strongbox in my backpack". To get this done, in the "/do" alias below, I've had to use %additem(%-1,@commands) when adding it to the list. The problem this causes is that if I want to "/do" more than one command in a row, all of them get added to the list as part of the first command, instead of different commands and it doesn't work. If I don't use %-1, and use %1 instead, that fixes the problem but then I can only use one-word commands. Does anyone have a solution for this?
If this sounds like a lot of work for nothing, just let me assure you that it would be a tremendous help to me in my scripts. Dragonrealms is of course the ideal place to test this, since that's where I'm going to use it. The two aliases /test1 and /test2 are included to help you test it out. Thanks in advance to anyone who can help.
#CLASS {Roundproof}
#ALIAS /do {#VARIABLE commands {%additem( %1, @commands)}}
#ALIAS /test1 {
hide
unhide
look
health
}
#ALIAS /test2 {
/do unhide
/do hide
/do look
/do inv
/do look in my backpack
}
#VARIABLE commands {}
#TRIGGER {^~>} {
#EXECUTE %item( @commands, 1)
#VARIABLE commands {%delitem( %item( @commands, 1), @commands)}
} "" {nocr|prompt}
#TRIGGER {^(%w)~>} {#IF %pos( "R", %1) {#ABORT} {
#EXECUTE %item( @commands, 1)
#VARIABLE commands {%delitem( %item( @commands, 1), @commands)}
}} "" {nocr|prompt}
#CLASS 0 |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sat Mar 09, 2002 2:03 pm |
What do you mean by:
"The problem this causes is that if I want to "/do " more than one command in a row, all of them get added to the list as part of the first command, instead of different commands and it doesn't work."?
Can't you do something like this:?
/do some commands;/do some other commands
Kjata |
|
|
|
dracx Beginner
Joined: 14 Oct 2000 Posts: 26 Location: USA
|
Posted: Sat Mar 09, 2002 4:49 pm |
If I /do command1;/do command2, when it's executed, it looks like this...
command1;/do command2
instead of like this
command1
command2
That is with the %-1 argument. With the %1 argument, I can do as you propose, but only with one word commands, which is not useful. |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Sat Mar 09, 2002 5:11 pm |
The %-1 grabs the entire line including
; if the alias contains the /
Alias:
#ALIAS /do {#VARIABLE commands {%additem( %1, @commands)}}
Stacked command:
/do add a pillow under my head;/do sleep
Result in @commands
add a pillow under my head;/do sleep
Alias
#ALIAS do {#VARIABLE commands {%additem( %1, @commands)}}
Stacked command:
do add a pillow under my head;do sleep
Result in @commands
add a pillow under my head|sleep
For some reason zMud does interpret the ;/
as the next command.
If I change the alias to plain do it works.
TonDiening
Beta Upgrading to 6.26 |
|
|
|
dracx Beginner
Joined: 14 Oct 2000 Posts: 26 Location: USA
|
Posted: Sun Mar 10, 2002 2:37 am |
Thanks Ton!
What on earth made you even try that? |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Sun Mar 10, 2002 3:03 am |
I attempt to script my role in a group as it
zone clears, you can see when I'm about 100%
scripted as I post very often :)
Almost time for a new secondary mud :)
TonDiening
Beta Upgrading to 6.26 |
|
|
|
|
|
|
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
|
|