|
VeldrinCrescent Newbie
Joined: 29 Nov 2005 Posts: 9
|
Posted: Thu Dec 09, 2010 12:54 pm
Problem with prompt trigger |
so I got this prompt trigger (for Achaea), where the big problem is, that it won't properly recolor my prompt when I sub it, it will color the 0-100 within the [] tag's but the main health/mana/endurance/willpower just stays green, and I can't figure out why (and anyone got any tips for optimizing this? )
^(\d+)h\, (\d+)m\, \d+e\, \d+w (\w+)\-
Code: |
#if (%1!=@healthcalc) {#sayp %ansi( reset)~(%if( %eval( %1-@healthcalc)>0, %ansi( 10), %ansi( 12))%eval( %1-@healthcalc)%ansi( reset)h~)" "}
#if (%2!=@manacalc) {#sayp %ansi( reset)~(%if( %eval( %2-@manacalc)>0, %ansi( 10), %ansi( 12))%eval( %2-@manacalc)%ansi( reset)m~)" "}
healthcalc = %1
manacalc = %2
#sub {%if(%eval(@health*100/@maxhealth)>75, %ansi(green), %if(%eval(@health*100/@maxhealth)>50, %ansi(yellow), %if(%eval(@health*100/@maxhealth)>35, %ansi(12), %ansi(red))))@health%ansi(green)~h%ansi( reset)~[%if(%eval(@health*100/@maxhealth)>75, %ansi(green), %if(%eval(@health*100/@maxhealth)>50, %ansi(yellow), %if(%eval(@health*100/@maxhealth)>35, %ansi(12), %ansi(red))))%eval( @health*100/@maxhealth)%ansi( reset)~]~, %ansi(reset)%if(%eval(@mana*100/@maxmana)>75, %ansi(green), %if(%eval(@mana*100/@maxmana)>50, %ansi(yellow), %if(%eval(@mana*100/@maxmana)>35, %ansi(12), %ansi(red))))@mana~m%ansi( reset)~[%if(%eval(@mana*100/@maxmana)>75, %ansi(green), %if(%eval(@mana*100/@maxmana)>50, %ansi(yellow), %if(%eval(@mana*100/@maxmana)>35, %ansi(12), %ansi(red))))%eval( @mana*100/@maxmana)%ansi( reset)~]~, %if(%eval(@end*100/@maxend)>75, %ansi(green), %if(%eval(@end*100/@maxend)>35, %ansi(yellow), %ansi(12)))@end%ansi(green)~e%ansi( reset)~[%if(%eval(@end*100/@maxend)>75, %ansi(green), %if(%eval(@end*100/@maxend)>35, %ansi(yellow), %ansi(12)))%eval( @end*100/@maxend)%ansi( reset)~]~, %if(%eval(@wp*100/@maxwp)>75, %ansi(green), %if(%eval(@wp*100/@maxwp)>35, %ansi(yellow), %ansi(12)))@wp%ansi(green)~w%ansi( reset)~[%if(%eval(@wp*100/@maxwp)>75, %ansi(green), %if(%eval(@wp*100/@maxwp)>35, %ansi(yellow), %ansi(12)))%eval( @wp*100/@maxwp)%ansi( reset)~] @experience %ansi( reset)%3~-}
#if (@flags.time) {#sayp " "%ansi(grey)~(%time(hh:mm:ss:zzz)~)%ansi(reset)}
#if (%class(fishing)) {fishingtime}
#if (@flags.paused) {#sayp " "%ansi(yellow)SYSTEM PAUSED%ansi(reset)}
#raiseevent onPrompt
#if (%pos(d, %3)) {#addkey affs deafness 1} {#addkey affs deafness 0}
#if (%pos(b, %3)) {#addkey affs blindness 1} {#addkey affs blindness 0}
#if (%pos(c, %3)) {#addkey defense cloak 1} {#addkey defense cloak 0;#sayp %ansi(12)" NO CLOAK"}
#if (%pos(k, %3)) {#addkey defense kola 1} {#addkey defense kola 0;#sayp %ansi(12)" NO KOLA"}
#if (%pos(x, %3)) {#addkey lostbals balance 0} {#addkey lostbals balance 1;#sayp %ansi(12)" NO BALANCE "%ansi(reset)}
#if (%pos(e, %3)) {#addkey lostbals equilibrium 0} {#addkey lostbals equilibrium 1;#sayp %ansi(12)" NO EQUILIBRIUM "%ansi(reset)}
scan_healing |
edit: it also lets me suffer a lot from the color bleeding through to the next line, which can be rather annoying |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Sun Dec 12, 2010 11:09 am |
Try this. I am assuming you are getting your stats from GMCP.
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<trigger name="myPrompt" priority="2" regex="true" newline="false" prompt="true" copy="yes">
<pattern>^(\d+)h, (\d+)m, \d+e, \d+w ([cexkdb]*)\-</pattern>
<value><![CDATA[$health = %1
$mana = %2
$flags = %3
#substitute @SubPrompt($flags)
$healthAmount = -(@healthCalc - $health)
$manaAmount = -(@manaCalc - $mana)
defense.cloak = %if(%pos("c",$flags),1,0)
defense.kola = %if(%pos("k",$flags),1,0)
affs.deafness = %if(%pos("d",$flags),1,0)
affs.blindness = %if(%pos("b",$flags),1,0)
lostbals.equilibrium = %if(%pos("e",$flags),0,1)
lostbals.balance = %if(%pos("x",$flags),0,1)
#if (@flags.time) {#sayadd %concat(" (",%time(hh:mm:ss:zzz),")")}
#if ($healthAmount != 0) {#sayadd { (<color %if($healthAmount > 0,"lime","red")>$healthAmount</color> h) }}
#if ($manaAmount != 0) {#sayadd { (<color %if($manaAmount > 0,"lime","red")>$manaAmount</color> m) }}
healthCalc = $health
manaCalc = $mana
#if (%class(fishing)) {fishingtime}
#if (@flags.paused) {#sayadd " <color yellow>SYSTEM PAUSED</color>"}
scan_healing
#raiseevent onPrompt
]]></value>
</trigger>
<func name="SubPrompt" copy="yes">
<value><![CDATA[$healthColor = %if((@health * 100 / @maxHealth) > 75, "green", %if((@health * 100 / @maxHealth) > 50, "yellow", %if((@health * 100 / @maxHealth) > 35, "red", "red")))
$manaColor = %if((@mana * 100 / @maxMana) > 75, "green", %if((@mana * 100 / @maxMana) > 50, "yellow", %if((@mana * 100 / @maxmana) > 35, "red", "red")))
$endColor = %if((@end * 100 / @maxEnd) > 75, "green", %if((@end * 100 / @maxEnd) > 35, "yellow", "red"))
$wpColor = %if((@wp * 100 / @maxWp) > 75, "green", %if((@wp * 100 / @maxWp) > 35, "yellow", "red"))
$xpStr = %concat("[",@experience,"]")
$flagsStr = %concat($flags,"-")
#return %concat("[<color ",$healthColor,">",@health,"</color><color green>h</color>][<color ",$manaColor,">",@mana,"</color><color green>m</color>][<color ",$endColor,">",@end,"</color><color green>e</color>][<color ",$wpColor,">",@wp,"</color><color green>w</color>]",$xpStr,$flagsStr)]]></value>
<arglist>$flags</arglist>
</func>
</cmud>
|
I punched in some fake numbers and it looks like this:
[4000h][5000m][15000e][15000w][75]x- (04:59:32:828) (1000 h) SYSTEM PAUSED
[3000h][5000m][15000e][15000w][75]x- (05:01:45:531) (-1000 h)
[3000h][3000m][15000e][15000w][75]x- (05:01:50:671) (-2000 m)
[5000h][5000m][15000e][5000w][75]x- (04:53:57:828)
Everything is colored just fine. Hard to tell on this background but it looks just how you were coloring it. |
|
|
|
VeldrinCrescent Newbie
Joined: 29 Nov 2005 Posts: 9
|
Posted: Sun Dec 12, 2010 4:59 pm |
Thanks I'll give it a try!
|
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Wed Dec 15, 2010 1:34 am |
Here is the whole class I used to test it if you want to load it into an untitled session and test. Just enter the alias RUNTEST. I have the trigger set to trigger on new line for the test.
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<class name="PromptTest" copy="yes">
<trigger name="myPrompt" priority="2" regex="true" copy="yes">
<pattern>^(\d+)h, (\d+)m, \d+e, \d+w ([cexkdb]*)\-</pattern>
<value><![CDATA[$health = %1
$mana = %2
$flags = %3
#substitute @SubPrompt($flags)
$healthAmount = -(@healthCalc - $health)
$manaAmount = -(@manaCalc - $mana)
defense.cloak = %if(%pos("c",$flags),1,0)
defense.kola = %if(%pos("k",$flags),1,0)
affs.deafness = %if(%pos("d",$flags),1,0)
affs.blindness = %if(%pos("b",$flags),1,0)
lostbals.equilibrium = %if(%pos("e",$flags),0,1)
lostbals.balance = %if(%pos("x",$flags),0,1)
#if (@flags.time) {#sayadd %concat(" (",%time(hh:mm:ss:zzz),")")}
#if ($healthAmount != 0) {#sayadd { (<color %if($healthAmount > 0,"lime","red")>$healthAmount</color> h) }}
#if ($manaAmount != 0) {#sayadd { (<color %if($manaAmount > 0,"lime","red")>$manaAmount</color> m) }}
healthCalc = $health
manaCalc = $mana
#if (%class(fishing)) {fishingtime}
#if (@flags.paused) {#sayadd " <color yellow>SYSTEM PAUSED</color>"}
scan_healing
#raiseevent onPrompt
]]></value>
</trigger>
<func name="SubPrompt" copy="yes">
<value><![CDATA[$healthColor = %if((@health * 100 / @maxHealth) > 75, "green", %if((@health * 100 / @maxHealth) > 50, "yellow", %if((@health * 100 / @maxHealth) > 35, "red", "red")))
$manaColor = %if((@mana * 100 / @maxMana) > 75, "green", %if((@mana * 100 / @maxMana) > 50, "yellow", %if((@mana * 100 / @maxMana) > 35, "red", "red")))
$endColor = %if((@end * 100 / @maxEnd) > 75, "green", %if((@end * 100 / @maxEnd) > 35, "yellow", "red"))
$wpColor = %if((@wp * 100 / @maxWp) > 75, "green", %if((@wp * 100 / @maxWp) > 35, "yellow", "red"))
$xpStr = %concat("[",@experience,"]")
$flagsStr = %concat($flags,"-")
#return %concat("[<color ",$healthColor,">",@health,"</color><color green>h</color>][<color ",$manaColor,">",@mana,"</color><color green>m</color>][<color ",$endColor,">",@end,"</color><color green>e</color>][<color ",$wpColor,">",@wp,"</color><color green>w</color>]",$xpStr,$flagsStr)]]></value>
<arglist>$flags</arglist>
</func>
<var name="healthCalc" copy="yes">2000</var>
<var name="manaCalc" copy="yes">1000</var>
<var name="flags" type="Record" copy="yes">
<value>paused=0</value>
<json>{"paused":0}</json>
</var>
<var name="experience" usedef="true" copy="yes">75</var>
<var name="mana" usedef="true" copy="yes">1000</var>
<var name="maxWp" usedef="true" copy="yes">15000</var>
<var name="wp" usedef="true" copy="yes">15000</var>
<var name="health" usedef="true" copy="yes">2000</var>
<var name="end" usedef="true" copy="yes">15000</var>
<var name="maxEnd" usedef="true" copy="yes">15000</var>
<var name="maxMana" usedef="true" copy="yes">5000</var>
<var name="maxHealth" usedef="true" copy="yes">5000</var>
<alias name="runtest" copy="yes">
<value>health = 5000
maxHealth = 5000
mana = 5000
maxMana = 5000
end = 15000
maxEnd = 15000
wp = 15000
maxWp = 15000
experience = 75
#show "5000h, 5000m, 15000e, 15000w cexdb-"
health = 3000
#show "3000h, 5000m, 15000e, 15000w cexdb-"
mana = 3000
health = 5000
#show "5000h, 3000m, 15000e, 15000w cexdb-"
end = 8000
mana = 1000
#show "5000h, 1000m, 8000e, 15000w cexdb-"
end = 15000
health = 2000
#show "2000h, 1000m, 15000e, 15000w cexdb-"</value>
</alias>
<var name="defense" type="Record" copy="yes">
<value>cloak=1|kola=0</value>
<json>{"kola":0,"cloak":1}</json>
</var>
<var name="affs" type="Record" copy="yes">
<value>deafness=1|blindness=1</value>
<json>{"deafness":1,"blindness":1}</json>
</var>
<var name="lostbals" type="Record" copy="yes">
<value>equilibrium=0|balance=0</value>
<json>{"equilibrium":0,"balance":0}</json>
</var>
<alias name="scan_healing" copy="yes"/>
<alias name="fishingtime" copy="yes"/>
</class>
</cmud>
|
|
|
|
|
|
|
|
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
|
|