|
Cuttlefish Apprentice
Joined: 28 Oct 2003 Posts: 164
|
Posted: Tue Nov 11, 2003 5:05 am
how to create this trigger from an alias |
I want to have a "name" alias that takes two strings and creates a trigger based on them. Here's what I have right now:
alias: name
#trigger {(%1)} {#sub {%%1 named %2}} people
Unfortunately, executing it like this:
name {the short, smelly dwarf} {Fnog the healer}
results in:
trigger pattern: ({the short, smelly dwarf})
trigger value: #sub {%1 named {Fnog the healer}}
This is obviously bad for a couple of reasons. First, the pattern should have the curly braces in it. Second, there shouldn't be any curly braces around Fnog the healer.
How should I go about this? I've tried many different variations but none have worked so far. |
|
|
|
megamog75 Enchanter
Joined: 20 Nov 2002 Posts: 627 Location: USA
|
Posted: Tue Nov 11, 2003 6:05 am |
As far as I know #sub does not understand how to do that
|
|
|
|
mr_kent Enchanter
Joined: 10 Oct 2000 Posts: 698
|
Posted: Tue Nov 11, 2003 10:04 am |
Assuming this is all and really what you want according to your post,
#ALIAS name {#TR {~{(%1)~}} {#sub {~{%%1~} named %-2}} people}
Should work by using:
name {the short, smelly dwarf} Fnog the healer |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Tue Nov 11, 2003 6:17 pm |
The best solution I came up with is to use the #VAR command, which will treat the {} as delimiters and automatically remove them.
Alias: name
Value:
#VAR temp1 %1
#VAR temp2 %2
#TR {(<@temp1>)} {#SUB {%%1 named <@temp2>}} |
|
|
|
Cuttlefish Apprentice
Joined: 28 Oct 2003 Posts: 164
|
Posted: Wed Nov 12, 2003 5:07 am |
(FYI: My escape char is , not ~)
sorry mr_kent, that wound up giving me this:
> name {the short, smelly dwarf} Fnog the healer
Triggers:
[...]
+ people: {({the short, smelly dwarf})} -> #sub {{%1} named Fnog the healer}
[...]
Lightbulb: This worked great. I added a couple of tweaks to it for my situation, such as adding the people class and unvarring to cleanup afterwards.
Here's my final alias:
#var temp1 %1
#var temp2 %2
#tr {(<@temp1>)} {#sub {%%1 named <@temp2>}} people
#unvar temp1
#unvar temp2
Usage:
name {the short, smelly dwarf} {Fnog the healer}
OR
name {the short, smelly dwarf} Fnog
Thanks to both of you so much for taking the time to post. |
|
|
|
mr_kent Enchanter
Joined: 10 Oct 2000 Posts: 698
|
Posted: Wed Nov 12, 2003 7:44 am |
Sorry it didn't work. It worked in my offline test. I don't know if it's the escape char difference, or what. Glad you got it working.
|
|
|
|
tbone235 Apprentice
Joined: 02 Nov 2002 Posts: 107 Location: Australia
|
Posted: Thu Nov 13, 2003 6:20 am |
actually there is another way to do it, unfortunately i can't find my script for doing it at the moment, but it basically involves doing a %exec on the #trigger command or something to that affect... saves all the temp stuff... when i find how i did it i'll let you know :)
|
|
|
|
|
|