|
danextpope Newbie
Joined: 11 Apr 2007 Posts: 9
|
Posted: Wed Apr 11, 2007 5:49 pm
alias help |
I'm trying to create an alias that will, for each argument, send the argument to the mud, wait for specific text, and then send the next, wait, &c. Obviously I can use #TEMP to delay until the text arrives (the text will be the same regardless of the item sent to the mud), but it's the body of the trigger I'm having trouble with, as I don't see any way to shift arguments (so %2 becomes %1, %3 becomes %2) to deal with all of them. Anyone have any suggestions?
|
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Wed Apr 11, 2007 6:09 pm |
Can you give us the exact output you're using for your trigger? Hard to help without nothing at all to go on. As for arguments, all I could suggested given the explanation you've currently provided us with... if you have several arguments inside the trigger line, use %w for them, inside the code, use %1 = , %2 = etc. %1 is accordingly first %w in line, %2 is second and so on.
Prog |
|
_________________ The Proud new owner of CMud.
--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
-------------------------------- |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Wed Apr 11, 2007 6:13 pm |
It sounds like you want to use a string list and the %pop command in your trigger. Still an example pasted from the mud of what you are trying to do would be helpful.
|
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
danextpope Newbie
Joined: 11 Apr 2007 Posts: 9
|
Posted: Wed Apr 11, 2007 6:40 pm |
The text is "following you." The arguments to the alias would be a series of move commands. The idea is to wait after each one until the object following me arrives in the current room before moving on to the next.
As for using string lists, I thought about that. I just would find something like:
cmove w w n n ne
to be a bit more intuitive than
cmove w|w|n|n|ne |
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Wed Apr 11, 2007 6:54 pm |
Code: |
#var movecoms {w|w|n|n|ne}
#alias cmove {%pop(movecoms)}
#trigger {following you} {cmove}
|
Perhaps this is what you mean?
Prog |
|
_________________ The Proud new owner of CMud.
--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
-------------------------------- |
|
|
|
danextpope Newbie
Joined: 11 Apr 2007 Posts: 9
|
Posted: Wed Apr 11, 2007 7:41 pm |
hmm, that's close, but not quite right. I do want the trigger to be a one shot, so maybe:
Code: |
#alias cmove {%pop(movecoms); #temp {following you} {cmove}}
|
Except there probably should be some sort of check to make sure that movecoms isn't empty. Maybe:
Code: |
#alias cmove {#if{%numitems(movecoms)>0}{%pop(movecoms); #temp {following you} {cmove}}{#echo Arrived}}
|
And, will need a second alias for setting movecoms:
Code: |
#alias setcmove {#var movecoms {%1}; cmove}
|
Does that all look about right? |
|
|
|
danextpope Newbie
Joined: 11 Apr 2007 Posts: 9
|
Posted: Wed Apr 11, 2007 8:58 pm |
Ok, did some experimentation, and came up with this, which almost works:
Code: |
#ALIAS cmove {#if {"%1" != ""} {
#var movelist {%1} {} {Narth}
#if {%numitems( @movelist)>0} {
%pop( movelist)
#temp {following you} {cmove}
} {#echo Arrived}
} {#if {%numitems( @movelist)>0} {
%pop( movelist)
#temp {following you} {cmove}
} {#echo Arrived}}}
|
It correctly sends the first command in @movelist, then waits for "following you". Unfortunately, when it gets that text it proceeds to send everything remaining in the list, rather than just the next one. Bit stumped by this one. As an alternative, I tried using a permanent trigger that used #T- to disable itself, with the cmove alias using #T+ to reenable it, but that option seems to work even less, as it only fires once. |
|
|
|
Wyndle Beginner
Joined: 28 Mar 2007 Posts: 20 Location: < here and there >
|
Posted: Thu Apr 12, 2007 1:18 pm |
I know it may not be exactly what you are looking for, but how about using the movelist to create a temporary path that can then be use with #slow, #stop, and #step triggers?
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Apr 12, 2007 1:55 pm |
You should really be using brackets () rather than braces {} around the expression part of the #if command. I'm surprised that %pop(movelist) works too, I'd've thought it should've been %pop(@movelist). Either way, you need to add an #exec command before it or it won't work with commands of more than one word. Perhaps you should also change the #var movelist {%1} to %-1 in case the commands contain spaces. Seems like you could make that alias a bit simpler by not repeating sections of code you don't need to:
#alias cmove {#if (%1) {#var movelist {%1}};#if (%numitems(@movelist)>0) {#exec %pop(@movelist);#temp {following you} {cmove}} {#echo Arrived}}
If you wanted a version that used #t- and #t+ you'd want something like this:
#alias cmove {#if (%1) {#var movelist {%1}};#if (%numitems(@movelist)>0) {#exec %pop(@movelist);#t+ CMoveTrig} {#echo Arrived;#t- CMoveTrig}}
#trig "CMoveTrig" {following you} {cmove} |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Thu Apr 12, 2007 9:55 pm |
Check the helpfile Fang %pos
Syntax: %pop(listname)
Retrieves the first item from the list named by "listname" and then removes this item from the list.
Note that the argument is the name of the list variable, not the @var reference. |
|
|
|
danextpope Newbie
Joined: 11 Apr 2007 Posts: 9
|
Posted: Fri Apr 13, 2007 6:48 am |
After some more experimentation, including breaking speedwalk, I had an epiphany, and came up with a dead simple way to do this, without any variables or permanent triggers, and without having to futz about with lists:
Code: |
#alias cmove {#if ('%1'=='') {#noop} {
#if ('%2'=='') {#slow %1} {
#slow %1
#alarm +0.5 {#temp {following you} {cmove %-2}}
}
}
}
|
I'm using #slow rather than just passing the args directly to the mud to make sure we actually get there, and to allow using the mapper's exit special commands to simplify things (so I can use “cmove w w n” rather than “cmove w "go gate" "go path"” as I might otherwise have to do). |
|
|
|
|
|