|
Toshiki Beginner
Joined: 20 Nov 2004 Posts: 14
|
Posted: Wed Dec 13, 2006 8:13 am
Trigger with %len and %copy using a ',' in syntax problem |
Code: |
#CLASS {Text|colorfader}
#ALIAS cf {#SHOW CF}
#VAR cfnum {0.571429014205933} {1}
#VAR cfnum2 {0}
#VAR cfnum3 {5} {1}
#VAR numcolors {7}
#VAR cf2 {%^BOLD%^BLUE%^%^WHITE%^t%^GREEN%^te%^RED%^tes%^GREEN%^test%^RESET%^}
#VAR cfrb {%^RESET%^BOLD%^RED%^|%^RESET%^RED%^|%^RESET%^BOLD%^BLACK%^|%^RESET%^|%^RESET%^BOLD%^BLACK%^|%^RESET%^BLUE%^|%^RESET%^BOLD%^BLUE%^}
#VAR cfwb {%^RESET%^BOLD%^BLACK%^|%^RESET%^|%^RESET%^BOLD%^WHITE%^|%^RESET%^BOLD%^CYAN%^|%^RESET%^CYAN%^|%^RESET%^BLUE%^|%^RESET%^BOLD%^BLUE%^}
#VAR cfcr {%^BOLD%^RED%^|%^WHITE%^|%^GREEN%^|%^WHITE%^|%^RED%^}
#VAR cfcg {%^BOLD%^GREEN%^|%^WHITE%^|%^RED%^|%^WHITE%^|%^GREEN%^}
#VAR cf {t|te|tes|test}
#VAR cfxm {%^BOLD%^BLUE%^|%^WHITE%^|%^GREEN%^|%^RED%^|%^GREEN%^|%^WHITE%^|%^BLUE%^}
[b]#TRIGGER {CF (%w) (%1) -(%1)} {
#var numcolors {%numitems( @cf%1)} {_nodef} {colorfader}
#var cf {} {_nodef} {colorfader}
#LOOP 1,%len( %4) {#var cf @cf|%copy( %4, %i, 1)}
#var cfnum {1} {1} {colorfader}
#var cfnum2 {0} {0} {colorfader}
#var cfnum3 {1} {1} {colorfader}
#var cf2 {} {_nodef} {colorfader}
#math cfnum %len( %4)
#math cfnum %norm( (@cfnum+0.0)/(@numcolors+0.0))
#add cf2 %item( @cf%1, @cfnum3)
#VAR cf %delItem( "", @cf)
#forall @cf {
#math cfnum2 (@cfnum2+1)
#if (@cfnum2>=@cfnum) {
#math cfnum3 (@cfnum3+1)
#add cf2 %item( @cf%1, @cfnum3)
#var cfnum2 {0} {_nodef} {}
}
#if (%i=" ") {#add cf2 " "}
#add cf2 {%i}
}
#add cf2 %^RESET%^
%2 @cf2
}[/b]
#CLASS 0 |
Ok the syntax for this is
cf <fadetype> <channel> - <message>
cf xm chat - Hello World
the problem i have with this is when i have a comma in the message, it causes a BIG problem. for example with 'Hello, World' it will print out
HHeHelHellHelloHello
I know this has something to do with the trigger, but i just can't figure how to fix it. Any help on fixing this would be nice. Other than that issue, it works pretty well. Some of the other symbols don't work with it either, but the comma is the big issue. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Dec 13, 2006 1:29 pm |
Firstly, it doesn't seem to be set as an oninput trigger and %1 isn't a valid wildcard. You also have it twice in the pattern.
If that doesn't fix it, then it's a problem with the way zMUD handles parameter expansion - it does it first which, as you say, can muck things up. I believe the solution is to put quotes "" around the %nn reference. Be much easier to do in CMUD :( |
|
|
|
Toshiki Beginner
Joined: 20 Nov 2004 Posts: 14
|
Posted: Wed Dec 13, 2006 4:03 pm |
Actually i am using zMUD now, and %1 does work as a wildcard. The way the triggerline is setup when i put in
cf xm tell guildmaster - Hello world
%1 = xm
%2 = tell guildmaster
%3 = tell guildmaster
%4 = Hello world
%5 = Hello world
the - makes sure that 'tell guildmaster' and 'Hello world' are seperated and read by the diffrent wildcards. This trigger works, but the ',' makes it go fubar. Cmud was just geting on my last nerve |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Dec 13, 2006 5:20 pm |
Strictly speaking, you shouldn't be using %nn in the pattern, but in the script. If it works, it shouldn't :P
Did putting quotes around the reference not help? |
|
|
|
Toshiki Beginner
Joined: 20 Nov 2004 Posts: 14
|
Posted: Wed Dec 13, 2006 7:47 pm |
What do i put the "" around?
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Dec 13, 2006 7:50 pm |
Around the %nn reference. So "%5" or whatever - because the problem is that the comma is being interpreted as a parameter separator, not as part of a string. That tells zMUD that the entire %5 is one string.
I've never actually used this syntax, so I'm not sure if you have to do any jiggling around to get it to work. But there's a reference here to how the syntax is obsolete in CMUD, so assume it'll work in zMUD. |
|
|
|
Toshiki Beginner
Joined: 20 Nov 2004 Posts: 14
|
Posted: Wed Dec 13, 2006 8:22 pm |
Yeah, that actually did solve my problem. Now the script works prefectly. Thanks again.
|
|
|
|
|
|