|
Nyvaana Beginner
Joined: 29 Jun 2002 Posts: 15 Location: Sweden
|
Posted: Sun Oct 12, 2003 2:56 pm
Cleaning up a prompt-colour script |
I wrote up the following, which is supposed to change the colour in the mud's prompt < 228h/228H 130v/130V P:Standing > to show the hitpoints in green, yellow and red for when the character is wounded. Which it does just fine, but every time a line from the mud needs to wrap, I get an output that looks like this
< 228h/228H 130v/130V P:Standing > Lohani assoc: 'Needa fix up the script I just wrote, it's got some... cute side-affects.'
228 130 130
< 228h/228H 130v/130V P:Standing > Gaikshaz ASSOC: 'hehe'
#TRIGGER "prompt" {< (%d)h/(%d)H (%d)v/(%d)V P:* >}
{#VARIABLE myhpstats {[@hp*100/@maxhp]}
#VARIABLE mymvstats {[@moves*100/@maxmoves]}
#PSUB %ansi( green)@maxhp %x2 // colour of maxhp
#IF (@myhpstats >= 100) {#PSUB %ansi( green)@hp %x1} //full health
#IF (@myhpstats < 100) {#PSUB %ansi( brown)@hp %x1} // few scratches yellow
#IF (@myhpstats < 90) {#PSUB %ansi( yellow)@hp %x1} // small wounds bright yellow
#IF (@myhpstats < 75) {#PSUB %ansi( magenta, high)@hp %x1} //few wounds bright magenta
#IF (@myhpstats < 50) {#PSUB %ansi( magenta)@hp %x1} //nasty wounds dark magenta
#IF (@myhpstats < 30) {#PSUB %ansi( red, high)@hp %x1} //pretty hurt bright red
#IF (@myhpstats < 15) {#PSUB %ansi( red)@hp %x1} //awful dark red
#PSUB %ansi( blue)@maxmoves %x4 // colour of maxmoves
#IF (@mymvstats >= 65) {#PSUB %ansi( blue)@moves %x3} // colour of good moves
#IF (@mymvstats < 65) {#PSUB %ansi( blue, high)@moves %x3} // colour of good moves
#IF (@mymvstats < 30) {#PSUB %ansi( cyan)@moves %x3} // colour of low moves} "" {prompt}
Any pointers? |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Oct 12, 2003 5:01 pm |
#PSUB can use a Y coordinate as well. You might try tacking something like %if(%len(%line)>90),1) to each of the #PSUBs. Ofcourse the 90 would have to be adjusted to match the actual length where wrapping occurs.
|
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Oct 12, 2003 5:20 pm |
I made numerous changes. %1, %2, %3, and %4 instead of @hp, @maxhp, @mv, and @maxmv which aren't calculated in this script. #MATH instead of #VAR for calculating. Color selection done ahead of time, so only one change is needed for each value. #PCOL instead of #PSUB since only color is being changed. %case to supply the actual colors.
#TR "prompt" {~< (%d)h/(%d)H (%d)v/(%d)V P:* ~>} {
#MATH myhpstats ((%1 * 100)/%2)
#MATH mymvstats ((%3 * 100)/%4)
#VAR hpcol 1
#IF (@myhpstats < 100) {#VAR hpcol 2}
#IF (@myhpstats < 90) {#VAR hpcol 3}
#IF (@myhpstats < 75) {#VAR hpcol 4}
#IF (@myhpstats < 50) {#VAR hpcol 5}
#IF (@myhpstats < 30) {#VAR hpcol 6}
#IF (@myhpstats < 15) {#VAR hpcol 7}
#VAR mvcol 1
#IF (@mymvstats < 65) {#VAR mvcol 2}
#IF (@mymvstats < 30) {#VAR mvcol 3}
#PCOL %case( @hpcol, green, brown, yellow, "hi,magenta", magenta, "hi,red", red) %x1
#PCOL green %x2
#PCOL %case( @mvcol, blue, "hi,blue", cyan) %x3
#PCOL blue %x4
} "" {prompt} |
|
|
|
Nyvaana Beginner
Joined: 29 Jun 2002 Posts: 15 Location: Sweden
|
Posted: Wed Oct 15, 2003 7:38 pm |
Oh! That's perfect, thankyou! Really wasn't sure I had put it together properly. (actually, I'm pretty sure it was ugly) Works like a charm.
*thinks* Now I gotta figure out -why- it works too. |
|
|
|
|
|
|
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
|
|