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
Kenna
Newbie


Joined: 03 May 2003
Posts: 2

PostPosted: Sat May 03, 2003 6:10 pm   

Problems with a trigger
 
Hello,

I have set up the following trigger:

#trigger {^There are * obvious exits: (*).} { #var exits {%replace( %1, ' ', |)}
}

An example of an exits line from the mud is:

There are two obvious exits: southeast and northwest.


(*) should, as far as I can see, capture 'southeast and northwest'. However it does not.

If I change the trigger to:

#trigger {^There are * obvious exits: &{exits}.} { #var exits {%replace( @exits, ' ', |)}
}

then it works, and 'southeast and northwest' is captured in the variable @exits. Why doesn't it work with (*) and %1 used?

Also, this trigger is part of a script to walk around randomly. However, sometimes it will not work for no apparent reason. It seems the trigger does not run. Can anyone suggest any reasons why it will not run, as it is confusing me?

The full script I have got so far is:

#class autokill
#var exits {}
#alias RandomMove {
#wait 2000
#exec %item( @exits, %random( 0, %numitems( @exits)))
}
#alias ShortExits {
#var exits {%replace( @exits, 'east', 'e')}
#var exits {%replace( @exits, 'west', 'w')}
#var exits {%replace( @exits, 'south', 's')}
#var exits {%replace( @exits, 'north', 'n')}
#var exits {%replace( @exits, 'northeast', 'ne')}
#var exits {%replace( @exits, 'southeast', 'se')}
#var exits {%replace( @exits, 'northwest', 'nw')}
#var exits {%replace( @exits, 'southwest', 'sw')}
#var exits {%replace( @exits, 'down', 'd')}
#var exits {%replace( @exits, 'up', 'u')}
}
#trigger {^There are * obvious exits: &{exits}.} {
#var exits {%replace( @exits, ' ', |)}
#var exits {%replace( @exits, ",", '')}
ShortExits
#var exits %delItem( "and", @exits)
RandomMove
}
#trigger {^The only obvious exit is &{exits}.} {
#var exits {@exits}
ShortExits
RandomMove
}
#class 0

Thank you in advance for any help.

Regards,
Kenna
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat May 03, 2003 7:42 pm   
 
I agree with you, (*) should capture 'southeast and northwest'. Furthermore, insofar as I have been able to test it, it does. The only thing I can recommend is to add another variable so you can find out if the problem lies in the parameter, %1, or in the function.
#trigger {^There are * obvious exits: (*).} {#VAR temp1 {%1};#var exits {%replace( %1, ' ', |)}}

As for either trigger sometimes failing, the most likely cause is embedded commas in your variables. Your script clearly indicates you expect to encounter commas when there are more than two exits, and these commas will interfere with the operation of the functions. Functions use commas to indicate the end of each parameter. The recommended solution is to use other delimiters around the variables which may contain commas.
#trigger {^There are * obvious exits: (*).} {#var exits {%replace( {%1}, ' ', |)}}

LightBulb
Advanced Member
Reply with quote
Kenna
Newbie


Joined: 03 May 2003
Posts: 2

PostPosted: Sat May 03, 2003 9:04 pm   
 
Thanks for the help :)

I found out in the end that it was a stupid mistake on my part causing the trigger not to work sometimes.

#exec %item( @exits, %random( 0, %numitems( @exits)))

should be:

#exec %item( @exits, %random( 1, %numitems( @exits)))

Otherwise sometimes it will return 0 and there is no 0 in string list @exits :)

However, I'm still clueless as to why (*) isn't working. It seems to store nothing in %1, therefore when i do :

#var temp1 {%1}

@temp1 also contains nothing.........
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat May 03, 2003 11:54 pm   
 
In that case, your pattern is somehow wrong and the trigger never fires because it doesn't match the actual MUD output. I've tested both the original trigger

#trigger {^There are * obvious exits: (*).} { #var exits {%replace( %1, ' ', |)}
}

and the modified test-version I suggested:

#trigger {^There are * obvious exits: (*).} {#VAR temp1 {%1};#var exits {%replace( %1, ' ', |)}}

They both work fine with the sample MUD output you provided:

There are two obvious exits: southeast and northwest.



LightBulb
Advanced Member
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