Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Canth
Newbie


Joined: 12 Jun 2002
Posts: 3

PostPosted: Wed Jun 12, 2002 7:53 pm   

Awkward triggers - autowalker/outside mapping
 
Hi,

I'm having a problem with a trigger
Say I want to trigger for 3 letters after a certain word eg:
#tr {^TEST: (?)(?)(?)}
And I want to do these actions:
#echo Trigger executing...
#if ('%1' = 'a') {#echo 1. this is a: '%1'} {#echo 1. This is not a: '%1'}
#echo 1: '%1'
#echo 2: '%2'
#echo 3: '%3'
#echo Trigger finished

So if you '#echo TEST: abc' it works fine and returns:
Trigger executing...
1. this is a: 'a'
1: 'a'
2: 'b'
3: 'c'
Trigger finished

if you #echo TEST: bbc it works fine and returns:
Trigger executing...
1. This is not a: 'b'
1: 'b'
2: 'b'
3: 'c'
Trigger finished

However, if you '#echo TEST: "bc' it returns:
Trigger executing...
2: 'b'
3: 'c'
Trigger finished

No proper evaluation is done on the first argument (the quote (")), even though the trigger pattern matches ok, and the numbering of the arguments recognises that b is the second argument.

I tried using the %ascii() function to test the value returned by %1, but basically it's ignored. The code waits to see a matching quote, and ignores anything in between.

I tried also storing the arguments in variables, and then evaluating the if statement using the variables, but that doesn't seem to work either.

Anyone know how to handle this? ie I'd like the #if statement to execute correctly and the echo to say something like 'this is not a: '"''

Thanks!
Canth

BTW this is with zMUD version 6.16
Reply with quote
Canth
Newbie


Joined: 12 Jun 2002
Posts: 3

PostPosted: Thu Jun 13, 2002 1:25 pm   
 
Hrm, reading this again, perhaps its not too clear. Here's what it's actually being used for:

I wanted to create an autowalker for a mud which shows outside locations like:
+-+
-#+
+++

where the player is the '#', roads are '-' and fields are '+'.

So I created a trigger:
^?(?)?$(?)#(?)$?(?)?$
This captures the characters in each of the cardinal directions (n, w, e, s).
As the action I have something like
possibleMoves=""
#IF ('%1' = '-') {#additem possibleMoves n}
#IF ('%2' = '-') {#additem possibleMoves w}
#IF ('%3' = '-') {#additem possibleMoves e}
#IF ('%4' = '-') {#additem possibleMoves s}
#delitem possibleMoves @reverseLastMove
#IF (%numitems(@possibleMoves)=1) {@possibleMoves}}

I also have aliases for each of the directions, eg:
#alias n {~n;reverseLastMove=s}
etc

So, the autowalker looks at the 4 characters representing the main directions on the map. If they are walkable (ie roads '-'), it adds the direction to a list (possibleMoves).
After it has checked each of the 4 directions, it then removes the reverse of the last direction it travelled (so if the last move was east, there should be a west in this map, but we don't want to walk there since thats where we have just come from). This should leave only valid directions on the walker.
If there is just one valid ditection, then we walk there. If there's more than one (or none ie a dead end), we wait for the user to decide what they want to do manually.

This works great, except aswell as there being fields (denoted '+'), there are also trees (denoted '"').
This is where the problem is. If any of the cardinal directions (north, south, east or west) contain trees, the action of the trigger gets messed up. Basically, if %1 (north) is trees, the %1 gets expanded to ", and the parser seems to continue looking through the rest of the action for a closing ", ignoring all the code inbetween, even though the code is on different lines, and the initial quote character has apostrophes around it. As I mentioned, I tried putting %ascii('%1') instead of just %1, but it does the same thing.
I tried capturing each argument in a variable (ie dirNorth = %ascii('%1');dirSouth = %ascii('%4') ... etc}, but the same problem with the parser looking for a closing quote and ignoring all code in between occurred.

Again, any ideas on how to approach this would be appreciated because this approach works excellently apart from this small problem.

Thanks!
Canth
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Jun 13, 2002 4:40 pm   
 
This looks like one of those rare cases when it might be worthwhile to disable the Strip " quotes option in the Script Parser preferences.

LightBulb
Senior Member
Reply with quote
Canth
Newbie


Joined: 12 Jun 2002
Posts: 3

PostPosted: Thu Jun 13, 2002 5:27 pm   
 
I was gonna try that but was afraid it would have adverse affects on my other scripts. Anywhere I could read more about what it actually does? Any idea what I should be looking for if I'm checking scripts for problems?

Thanks
Canth
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Jun 13, 2002 6:42 pm   
 
Yes, if you are using "'s elsewhere in your scripts they'll probably need to be changed. Whether this trigger is worth the difficulties it will cause elsewhere is a choice you'll have to make.

LightBulb
Senior Member
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Jun 14, 2002 1:23 am   
 
quote:

Hi,

I'm having a problem with a trigger
Say I want to trigger for 3 letters after a certain word eg:
#tr {^TEST: (?)(?)(?)}
And I want to do these actions:
#echo Trigger executing...
#if ('%1' = 'a') {#echo 1. this is a: '%1'} {#echo 1. This is not a: '%1'}
#echo 1: '%1'
#echo 2: '%2'
#echo 3: '%3'
#echo Trigger finished

So if you '#echo TEST: abc' it works fine and returns:
Trigger executing...
1. this is a: 'a'
1: 'a'
2: 'b'
3: 'c'
Trigger finished

if you #echo TEST: bbc it works fine and returns:
Trigger executing...
1. This is not a: 'b'
1: 'b'
2: 'b'
3: 'c'
Trigger finished

However, if you '#echo TEST: "bc' it returns:
Trigger executing...
2: 'b'
3: 'c'
Trigger finished

No proper evaluation is done on the first argument (the quote (")), even though the trigger pattern matches ok, and the numbering of the arguments recognises that b is the second argument.

I tried using the %ascii() function to test the value returned by %1, but basically it's ignored. The code waits to see a matching quote, and ignores anything in between.

I tried also storing the arguments in variables, and then evaluating the if statement using the variables, but that doesn't seem to work either.

Anyone know how to handle this? ie I'd like the #if statement to execute correctly and the echo to say something like 'this is not a: '"''

Thanks!
Canth

BTW this is with zMUD version 6.16



First off, what's the #IF for? It seems like you have a reporting error in there where you compare %1 to 'a'--if it's true then you echo "This is a: 'a'", but if it's false you echo "This is not a: 'b'" (or whatever %1 happens to be).

Second, have you messed around with %expand()? Totally unsure if it can solve your problem, but that's what this function was basically designed for.

li'l shmoe of Dragon's Gate MUD
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net