|
AzCowboy Adept
Joined: 09 Nov 2000 Posts: 222 Location: USA
|
Posted: Thu Aug 15, 2002 1:52 am
Need help with door script |
Ok, one of the muds I play on (Towers of Jadri) has an exit line like this:
[Exits: (D)north east (D)south west]
or:
[Exits: (O)north east (O)south west]
with the D's being closed doors, and the O's open. I'm trying to script it to automatically add the doors to the map, when in mapping mode. Here's the script I'm using:
#TRIGGER {~[(%d)hp (%d)en~]} {#var hp %1;#var en %2;#tag prompt;#gag;#if (%class Automapper) { #while (%numitems( @doors)) { #door %pop( doors)}} { #while (%numitems( @doors)) { #deli doors 1}}}
#TRIGGER {~(O~)(%w)} {#sub %1;#additem doors %1} "System|Automapper"
#TRIGGER {~(D~)(%w)} {#sub %1;#additem doors %1} "System|Automapper"
Now, what SHOULD happen, is that for every door, it adds the direction to the doors list variable, and removes the door indication, then when it gets to the prompt, it adds the doors on the map. It works, some of the time, but occassionally I'll get a line like this:
[Exits: north (D)east south (D)west]
and it produces output similar to this:
[Exits: north east south west
#additem doors west]
Any suggestions? |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Thu Aug 15, 2002 3:18 am |
Try using the direction wildcard %t, this should eliminate the possibility of the ] being included in the in captured word. Also as a general rule any time %1..%99 is not being used for a number it should be enclosed in quotes to prevent script confusions like you are seeing.
One fine point you do not need the second #WHILE loop in your prompt trigger, as %pop deletes the items as it goes. Also if it ever failed to do so you would have an infinite loop and would be unhappy. |
|
|
|
AzCowboy Adept
Joined: 09 Nov 2000 Posts: 222 Location: USA
|
Posted: Thu Aug 15, 2002 4:05 am |
The second #while loop executes if mapping is turned off, and just clears the list variable.
They'll never BOTH execute.
And I'll try your recommendations as soon as my mud comes back online. *twiddle*
AzCowboy |
|
|
|
AzCowboy Adept
Joined: 09 Nov 2000 Posts: 222 Location: USA
|
Posted: Thu Aug 15, 2002 4:21 am |
I tested it offline, and it still doesn't work with %t ended up with 4 triggers like this:
#TRIGGER {~(O~)(east)} {#sub "%1";#additem doors "%1"} "System|Automapper"
now it works... not very elegant, though. Ah, well.. I guess I've kludged worse.
AzCowboy |
|
|
|
AzCowboy Adept
Joined: 09 Nov 2000 Posts: 222 Location: USA
|
Posted: Thu Aug 15, 2002 4:23 am |
Actually:
#TRIGGER {~(?~)(east)} {#sub "%1";#additem doors "%1"} "System|Automapper"
so that the same four triggers match open or closed doors.
Now, if my mud would just come back up. *sigh* Wish I had the admins phone #, I'd call him up and whine.
AzCowboy |
|
|
|
|
|