|
Tylander Newbie
Joined: 15 May 2011 Posts: 2
|
Posted: Sun May 15, 2011 10:43 pm
Trigger Ansi |
Code: |
<trigger priority="99999" ansi="true" id="364">
<pattern>^You get %1 from corpse of %2.$</pattern>
<value>#CALL %1
#FORALL @MudWideRares {#SHOW %i " = " %1;#IF (%match(%i, %1)) {put ~"%1~" ~"An Exploding Star~";#EXIT}}
cdonate ~"%1~"</value>
</trigger>
<var name="MudWideRares" type="StringList" sorted="1" id="369">
<value>%e[1;30mA Token for Good Be%e[0;32mh%e[1;32ma%e[0;32mv%e[1;30miour%e[0m|Crimson Scaled Armor</value>
<json>["%e[1;30mA Token for Good Be%e[0;32mh%e[1;32ma%e[0;32mv%e[1;30miour%e[0m","Crimson Scaled Armor"]</json>
</var> |
I can get this to start working when I turn off the ansi and delete the ansi colors in the variable stringlist, but I can't get it to work correctly when I want to do it in color, can anyone who knows has encountered this problem. Also #Show command say it is reading the value just fine but then is copying straight over without expanding the variables the text. What function/command would I use to do this? |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon May 16, 2011 3:04 am |
1) Don't use %1...%99 in trigger patterns. If you don't know what wildcards you need to use, see the patternmatching helpfile.
2)#call %1? Is whatever you are trying to match in %1 defined as a function? Not sure what you're attempting to do here, but #CALL is probably not what you want to use.
3)%match() isn't really needed in this case, but probably an issue of several ways to do things. I would just do %i = %1 since in an ansi trigger %1...%99 will preserve ansi codes matched in the pattern.
4)if the #forall stops matching, it's likely because the ansi codes in your variable are not precisely in the position they are supposed to be in. "%e[35m An item name" is not the same as " %e[[35mAn item name".
5)implicit concatenation (ie, ~"stuff~") can be bad.
The only other issues I've ever come across with ansi codes are:
1)CMud has certain situations where it abbreviates color codes. Some of them are handled such that %e[35m is equivalent to %e[0;35m, but some I think still aren't and comparisons end up failing because of this.
2)in some situations, the %e isn't recogized as an escape sequence and either the code is returned literally or something like 4095T shows up. Again, when this happens, comparisons may fail. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Tylander Newbie
Joined: 15 May 2011 Posts: 2
|
Posted: Wed May 18, 2011 12:11 am |
1: Okay this I'l' do but should work with %1 and %2 regardless.
2: Forgot to take that out as I though that would evaluate the string turning it into numbers|letters
3: Aren't they much of the same thing, I mean match should be a more correct way of checking the comparsion.
4: Yes, I ended up putting #show to see what was showing and then view it on in my editor, found some interesting things
5: Same as number 3 as I put them only where they are needed and they shouldn't be doing anything but just those next characters
Here is the finish product:
Code: |
<trigger priority="3720" ansi="true" enabled="false" id="372">
<pattern>^You get ($corpseObject:*) from corpse of ($corpseMobile:*).$</pattern>
<value>#FORALL @MudWideRares {#IF ($corpseObject = %i) {put ~"%stripansi($corpseObject)~" ~"An Exploding Star~";#EXIT}};cdonate ~"%stripansi($corpseObject)~"
</value>
<arglist>$corpseObject,$corpseMobile</arglist>
</trigger>
<var name="MudWideRares" type="StringList" sorted="2" id="369">
<value><![CDATA[[1;30mA Token for Good Be[0;32mh[1;32ma[0;32mv[1;30miour[0m]]></value>
<json><![CDATA[["[1;30mA Token for Good Be[0;32mh[1;32ma[0;32mv[1;30miour[0m"]]]></json>
</var> |
See the problem was I was trying to evaluate it with a %e in front of the codework to produce the codes so I was looking around for it, then I tried with the show in the inside and outside and came up with this example of a <- appearing in place of the %e so I copied that and I found that to place exactally the code of the $corpseObject. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed May 18, 2011 1:44 am |
1) Zmud let you get away with using %1 etc. inside trigger patterns, but even there it was not correct. Cmud won't let you get away with this incorrect coding.
|
|
|
|
|
|