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
Zene
Beginner


Joined: 10 Jul 2002
Posts: 26
Location: Canada

PostPosted: Sat Dec 21, 2002 7:29 am   

Variable with trigger?
 
Hi, i'm used to being able to pattern much constant characters and such, i'm trying to make a trigger that pattern matches characters, but at the same time capture all these variables.

For example, to capture all the directions out of a room, once you've walked into it:
The mud output for me is:

[Exits: north east south west]
or
[Exits: up down]

It can have upto 6 different directions in the part with the directions. I'm still using 6.16 and am hoping it won't be much of a different with 6.40. But the trigger i have set up that DOESN'T seem to work is as follows:

#TR {^~[Exits: {(%w) (%w) (%w) (%w) (%w) (%w)|(%w) (%w) (%w) (%w) (%w)|(%w) (%w) (%w) (%w)|(%w) (%w) (%w)|(%w) (%w)|(%w)}~]*} {#VAR d1 {};#var d2 {};#var d3 {};#var d4 {};#ADDITEM exit %1;#ADDITEM exit %2;#ADDITEM exit %3;#ADDITEM exit %4}

which only captures the first 4 directions...but doesn't seem to work...
once i put the {}s in the trigger..it doesn't seem to recognize them at all..

Does anyone know any possible fixes to this?

Any help would be appreciated.

Thanks.

Z
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Dec 21, 2002 8:20 am   
 
quote:

Hi, i'm used to being able to pattern much constant characters and such, i'm trying to make a trigger that pattern matches characters, but at the same time capture all these variables.

For example, to capture all the directions out of a room, once you've walked into it:
The mud output for me is:

[Exits: north east south west]
or
[Exits: up down]

It can have upto 6 different directions in the part with the directions. I'm still using 6.16 and am hoping it won't be much of a different with 6.40. But the trigger i have set up that DOESN'T seem to work is as follows:

#TR {^~[Exits: {(%w) (%w) (%w) (%w) (%w) (%w)|(%w) (%w) (%w) (%w) (%w)|(%w) (%w) (%w) (%w)|(%w) (%w) (%w)|(%w) (%w)|(%w)}~]*} {#VAR d1 {};#var d2 {};#var d3 {};#var d4 {};#ADDITEM exit %1;#ADDITEM exit %2;#ADDITEM exit %3;#ADDITEM exit %4}

which only captures the first 4 directions...but doesn't seem to work...
once i put the {}s in the trigger..it doesn't seem to recognize them at all..

Does anyone know any possible fixes to this?

Any help would be appreciated.

Thanks.

Z



You cannot, cannot, cannot use wildcards within a stringlist pattern.

incorrect Trigger:
#trigger {This is a {%w|%d}.} {}

correct Trigger:
#trigger {This is a {test|123}.} {}
#trigger {This is a {@variable}} {}

You wouldn't want a stringlist in this pattern, anyways. You instead would want to capture the info in one lump sum and parse it out within the trigger code yourself.

#triger {~[Exits: (*)~]} {#forall %replace("%1"," ", "|") {#additem Exit %i}}

li'l shmoe of Dragon's Gate MUD
Reply with quote
Zene
Beginner


Joined: 10 Jul 2002
Posts: 26
Location: Canada

PostPosted: Sat Dec 21, 2002 10:39 am   
 
Thanks for the help! That worked great...except now i run into a general problem.

Took me awhile to figure out what the problem was :P hehe..but now that i did here it is...

My alias works like this:

#ALIAS exiton {#TRIG {^~[Exits: (*)~]} { #forall %replace(%1," ", "|") {#additem Exit %i} ; #sa exit is @exit;processdirs;#TRIG {^~[H:*} {exitoff;promptoff;#write 2 nextroom;#read 2} "abyss" {nocr|prompt}} "abyss"}

which is within a class called abyss..except when it makes the first trigger and tries to use the %1 of the trigger but ends up using the %1 of the alias (i'm assuming this is the problem).

How can i make the trigger within the alias use the %1 of the first trigger (ie. the directions from which the trigger triggers off of..)..

Man those last 2 paragraphs must be confusing...But if anyone understood it..please help me out...Spent the last hour trying to debug this one line :P

Thanks again :)

Z
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Sat Dec 21, 2002 11:14 am   
 
What you are doing is making a trigger every time you execute the alias. Better solutions would be temporary triggers (automatically deleted once they trigger once) or always having the triggers there but turning them on and off as necessary (using either classes or trigger IDs).

So first replace your #TRIG statements with #TEMP. That won't fix the problem with %1 referring to the alias arguments instead of the trigger arguments, but fortunately, you can defer expansion by using %%1 instead of %1.

 - Charbal
Reply with quote
Zene
Beginner


Joined: 10 Jul 2002
Posts: 26
Location: Canada

PostPosted: Sat Dec 21, 2002 2:19 pm   
 
%%1...ingenius! As I was waiting for sleep to take me last night, I thought of making a subclass with just this trigger inside of it, but the %%1 works even better!

Thanks again for the help.

Z
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