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


Joined: 19 Mar 2004
Posts: 9
Location: Canada

PostPosted: Sat Apr 10, 2004 7:46 am   

adding triggers from within aliases...
 
Here is what i'm trying to do...

I type in qtsetup {You are here.} {Run away.} it does:
#var QT_Trig {%1}
#var QT_Action {%2}

I type in qtadd, it does:
#TRIGGER {<@QT_Trig>} {#SUBSTITUTE {%format("&-32s", @QT_Trig)@QT_Action}} {QT}

The desired output would be:
#TRIGGER {You are here.} {#SUBSTITUTE {%format("&-32s", You are here.)Run away.}} {QT}

But instead i get this:
#TRIGGER {You are here.} {#SUBSTITUTE {%format("&-32s", @QT_Trig)@QT_Action}} {QT}

I don't get it.. Anyone got any suggestions?
Reply with quote
jessew
Apprentice


Joined: 03 Mar 2003
Posts: 141

PostPosted: Sat Apr 10, 2004 7:56 am   
 
You left out the <>s to expand the variables on the command part of the trigger?
not sure if this is what you mean
#TRIGGER {<@QT_Trig>} {#SUBSTITUTE {%format("&-32s", <@QT_Trig>)<@QT_Action>}} {QT}

Cheers Jesse
Reply with quote
tobei
Newbie


Joined: 19 Mar 2004
Posts: 9
Location: Canada

PostPosted: Sat Apr 10, 2004 8:01 am   
 
#TRIGGER {You are here.} {#SUBSTITUTE %format( "&-32s", <@QT_Trig>)<@QT_Action>}} {QT}
is the output

for some reason its not expanding the variables when its performing the #TRIGGER...
Reply with quote
tobei
Newbie


Joined: 19 Mar 2004
Posts: 9
Location: Canada

PostPosted: Sat Apr 10, 2004 8:10 am   
 
Here is what I have right now...
#ALIAS qtsetup {#VARIABLE QT_Trig {%1};#VARIABLE QT_Action {%2}}
#ALIAS qtadd {#TRIGGER {<@QT_Trig>} {#SUBSTITUTE {%format( "&-31s", @QT_Trig)" "@QT_Action}} {QT}}

The output is..
#TRIGGER {You are here.} {#SUBSTITUTE {%format( "&-31s", @QT_Trig)" "@QT_Action}} {QT}

I want it to look like:
#TRIGGER {You are here.} {#SUBSTITUTE {%format( "&-31s", You are here.) Run away.}} {QT}

As stated before.. just an update though...
Reply with quote
jessew
Apprentice


Joined: 03 Mar 2003
Posts: 141

PostPosted: Sat Apr 10, 2004 9:45 am   
 
K, I misunderstood what you meant. The problem is #trigger doesnt parse variables till after the trigger is fired. And variables can be used in the pattern part as well so thats why there not being expanded.

But i came up with this dirty way of doing it, no doubt there is an easier way of doing this :P but it werks!

Uses concat to build the trigger line , allowing the variables to be expanded then executes the newly built trigger line
Code:

#ALIAS qtadd {#exec %concat("#TRIGGER {", @QT_Trig,"} {#SUBSTITUTE {%format(~"&-31s~"~,",@QT_Trig,") ",@QT_Action,"}} {QT}")}


And unless there's a reason you need to do it with the variables it will be much easier just to do it like this:
Code:
#alias qtadd {#TRIGGER {%1} {#substitute {%format("&-32s", %1) %2}} {QT}}



Cheers Jesse
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