|
Josiah.Bruns Apprentice
Joined: 04 Mar 2007 Posts: 103
|
Posted: Sat Mar 17, 2007 5:42 am
#Alias waiting for prompt between commands |
i am trying to create an #alias that will execute a few commands, however i want to wait for the prompt to show before i execute the second command in the #alias and then wait for the promt to show and Execute the third command and so on. Any Idea's?
I was looking at maybe making a #temp trigger or using #alarm or maybe #wait but i didn't find a way that really tickled my fancy. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Mar 17, 2007 5:54 am |
Two options - #temp, and a permanent trigger that's activated by the alias.
Option 1:
#alias dostuff {some commands #temp {prompt pattern} {some more commands;#temp {prompt pattern} {some more more commands}}}
but as you can see, that stacks up quickly. With a fixed set of commands:
#var StuffList ""
#alias dostuff {#var StuffList "something|something else|another command";#exec %pop(@StuffList);#t+ DoStuffTrig}
#trig "DoStuffTrig" {Prompt Pattern} {#exec %pop(@StuffList);#if (!%numitems(@StuffList)) {#t- DoStuffTrig}}
It's a bit more complex with a dynamic set of commands. |
|
|
|
Josiah.Bruns Apprentice
Joined: 04 Mar 2007 Posts: 103
|
Posted: Sat Mar 17, 2007 5:59 am |
This seems to be working... can you see anything wrong with doing it this way? or maybe a cleaner way than this?
Code: |
#ALIAS AutoMap {
%item( @RoomExits, %random( 1, %numitems( @roomexits)))
#ALARM {%roomexit( ,@RoomExits)}{prompt} <------ this is the command thats causing the pause between line1 of my alias and line 3
glance
} |
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Mar 17, 2007 6:07 am |
Yes, there is a problem with that. I have no idea why that is working. #alarm shouldn't even function that way, delaying commands after it - what #alarm does is create a trigger that waits a certain amount of time and fires rather than matching a pattern. The "glance" command is independent of the creation of that trigger and so shouldn't be affected.
The syntax you're using for #alarm itself also isn't valid. There should be a space between separate parameters for one, and secondly %roomexit won't be returning a proper time string (they should contain only 0-9.:*+) so even if you were to change it to the more proper "#alarm {%roomexit(,@RoomExits)} {prompt}" it still wouldn't fire correctly. I have no idea how that command knows to wait the right amount of time.
Also, one probably unintended sideffect of your usage of %roomexit is that it's going to set the exit string of the current mapper room to @RoomExits. I'm pretty sure you didn't intend that.
The proper way to use #alarm for something like this is this:
#alarm +3 {glance}
which will create an alarm trigger to glance in 3 seconds and then delete itself. |
|
|
|
Josiah.Bruns Apprentice
Joined: 04 Mar 2007 Posts: 103
|
Posted: Sat Mar 17, 2007 1:48 pm |
is there a way to put comments in my code? i tried a few times using different options that i read about in the help files, but i am assumming i need to have a config setting set properly to use a certain comment. Once i had // working i think but them it quit working.
|
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Sat Mar 17, 2007 2:07 pm |
What Fang is trying to say is that you should NOT be using that code, it could only be some tear in the fabric of space and time that is causing it to work at all and it therefore must be inherently evil.
He mentioned above creating a permanent trigger just for being used with this alias and I think you should use that option.
Code: |
#TRIGGER "AutoMapT" {Your prompt pattern} {glance;do other stuff;#T- AutoMapT} "Your mapping class name here." {disable} |
Creates the trigger.
I did not make this an on prompt trigger but you could go into the GUI and tick the on prompt option once the trigger is made.
Code: |
#ALIAS AutoMap {
%item( @RoomExits, %random( 1, %numitems( @roomexits)))
#T+ AutoMapT
} |
Creates the Alias.
Any commands you wanted to do after waiting in the alias should be put into the trigger BEFORE the #T- AutoMapT command is sent. |
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
|
|