Cute little prompt Sub

by relaren

Back to Mechanic's Corner.

relaren2007-02-16 21:43:04
* * * UPDATED TO INCLUDE COLOUR CHANGES! * * *
* * * FULLY UPDATED SCRIPT IS FURTHER DOWN THE THREAD (Post #14) * * *

OK, as promised, yet another cute little bit of eye candy for you zMUD users.
Fed up with your normal boring prompt?

CODE
1820h, 1570m, 1820e, 10p, 8000en, 8000w esSix-


How about something a bit more snazzy?

CODE
<1820/1820 1570/1820 1820/1820 10 8000 8000 (esSix-)


Actually looks a lot better in the client, all nicely coloured and whatnot, so on with the script!

Enjoy!

CODE
#CLASS {Prompt Stuff}
#VAR health {}
#VAR maxhealth {}
#VAR endurance {}
#VAR maxendurance {}
#VAR mana {}
#VAR maxmana {}
#VAR willpower {}
#VAR maxwillpower {}
#VAR ego {}
#VAR maxego {}
#VAR power {}
#VAR stats {}
#REGEX {^(\\d+)h, (\\d+)m, (\\d+)e, (\\d+)p, (\\d+)en, (\\d+)w (+)$} {health=%1;mana=%2;ego=%3;power=%4;endurance=%5;willpower=%6;stats=%7;#variable healthperc %eval( %float( @health)/@maxhealth*100);#variable manaperc %eval( %float( @mana)/@maxmana*100);#variable egoperc %eval( %float( @ego)/@maxego*100);#substitute {%ansi(grey)~<%if( @healthperc >= 60, %ansi( green), "")%if( @healthperc >= 30 and @healthperc < 60, %ansi( high, yellow), "")%if( @healthperc < 30, %ansi( high, red), "")@health~/%ansi(green)@maxhealth %if( @manaperc >= 60, %ansi( green), "")%if( @manaperc >= 30 and @manaperc < 60, %ansi( high, yellow), "")%if( @manaperc < 30, %ansi( high, red), "")@mana/%ansi(green)@maxmana %if( @egoperc >= 60, %ansi( green), "")%if( @egoperc >= 30 and @egoperc < 60, %ansi( high, yellow), "")%if( @egoperc < 30, %ansi( high, red), "")@ego/%ansi(green)@maxego%ansi(yellow) @power @endurance @willpower%ansi(grey)~> %ansi(green)~(%ansi(high,red)@stats%ansi(green)~) %ansi(high,red)~}} "Prompt Stuff"
#REGEX {Health : (\\d+)/(\\d+)} {health=%1;maxhealth=%2} "Prompt Stuff"
#REGEX {Endurance : (\\d+)/(\\d+)} {endurance=%1;maxendurance=%2} "Prompt Stuff"
#REGEX {Mana   : (\\d+)/(\\d+)} {mana=%1;maxmana=%2} "Prompt Stuff"
#REGEX {Willpower : (\\d+)/(\\d+)} {willpower=%1;maxwillpower=%2} "Prompt Stuff"
#REGEX {Ego    : (\\d+)/(\\d+)} {ego=%1;maxego=%2} "Prompt Stuff"
#CLASS 0


As soon as I get round to it, I will have it change colour as you drop below a certain percentage of each stat, but in the meantime, get used to that!

EDIT: As always, copy-paste that into notepad and import as Script(ASCII)

Also, if any Mods are reading this, any chance we could have a new section for posting scripts? Would be so much easier to contend with. Thanks.
relaren2007-02-16 22:52:02
OK, here is a challenge for somebody. I cannot see why this isn't working. Basically, I am trying to show the gain/loss from each stat as a change happens. You will see what I mean after looking at it.

10 points to the first person to correct this!

CODE
#substitute {%ansi(grey)~<%if( @healthperc >= 60, %ansi( green), "")%if( @healthperc >= 30 and @healthperc < 60, %ansi( high, yellow), "")%if( @healthperc < 30, %ansi( high, red), "")@health~/%ansi(green)@maxhealth%if( @hchange < 0 and !%null(@hchange), ~ ~+%abs(@hchange))%if( @hchange > 0 and !%null(@hchange), ~ ~-@hchange) %if( @manaperc >= 60, %ansi( green), "")%if( @manaperc >= 30 and @manaperc < 60, %ansi( high, yellow), "")%if( @manaperc < 30, %ansi( high, red), "")@mana/%ansi(green)@maxmana%if( @mchange < 0 and !%null(@mchange), ~ ~+%abs(@mchange))%if( @mchange > 0 and !%null(@mchange), ~ ~-@mchange) %if( @egoperc >= 60, %ansi( green), "")%if( @egoperc >= 30 and @egoperc < 60, %ansi( high, yellow), "")%if( @egoperc < 30, %ansi( high, red), "")@ego/%ansi(green)@maxego%if( @echange < 0 and !%null(@echange), ~ ~+%abs(@echange))%if( @echange > 0 and !%null(@echange), ~ ~-@echange)%ansi(yellow) @power @endurance @willpower%ansi(grey)~> %ansi(green)~(%ansi(high,red)@stats%ansi(green)~) %ansi(high,red)~}
Unknown2007-02-17 00:49:17
Your prompt trigger isn't a prompt trigger in the true sense, which is fine if you like the extra carriage returns. I prefer to use the nocr|prompt options on prompt triggers. If you did make that change, you'd probably have to switch from #SUB to #PSUB.

The color changes and calculations are pretty, I'll agree with that, but they'll slow you down immensely in any real combat situation. Might want to have an option to toggle all the prompt extras.

P.S. You forgot to give us the code for the calculation of the "change" variables. I'm assuming you have variables to store the last values and then the second set for the current values, and you do the calculations just fine. Without the math, though, I could really tell you what's broken in that script.
laeric2007-02-17 04:50:00
Basically you want to compare your health/mana/ego/power etc to the prompt before it. This way you are using your previous's prompt's health and mana in your prevHealth prevMana variables. Then you do a check to see if your prevhealth is not your curhealth (a change). And etc: I think this works

CODE
#var prevHealth curHealth
#var prevMana curMana
#var curHealth %1
#var curMana %1

#if (@prevHeath!=@curHealth) {
  #math diffHealth (@curHealth-@prevHealth)
  #if (@diffhealth > 0) {
    #say "+"@diffhealth"h"
    } {
    #say @diffhealth"h"
    }
  }
}


Let me know how it works out (and if the zmud script is correct =p)

EDIT: Ahhh I see your sub is one line so you would have to do this as a function call hrm. What you could do is do this piece of script before your actual sub, and do the #if @diffhealth if statement as a function in there to figure out whether to display +xh, or leave it as -xh.
relaren2007-02-17 08:17:08
QUOTE(Zarquan @ Feb 17 2007, 12:49 AM) 383946
Your prompt trigger isn't a prompt trigger in the true sense, which is fine if you like the extra carriage returns. I prefer to use the nocr|prompt options on prompt triggers. If you did make that change, you'd probably have to switch from #SUB to #PSUB.

The color changes and calculations are pretty, I'll agree with that, but they'll slow you down immensely in any real combat situation. Might want to have an option to toggle all the prompt extras.

P.S. You forgot to give us the code for the calculation of the "change" variables. I'm assuming you have variables to store the last values and then the second set for the current values, and you do the calculations just fine. Without the math, though, I could really tell you what's broken in that script.


Oh, yes. Sorry, I will go and hide in my little corner now, heh, OK, here is what I am doing. It is as simple as this.

CODE
#VAR hchange %eval( @health - %1)
#VAR mchange %eval( @mana - %2)
#VAR echange %eval( @ego - %3)


Also, with regards to the lag, yes, I agree there. Maybe more so for teams, though nonetheless changes have been made. Thankyou.
relaren2007-02-17 08:24:27
QUOTE(Laeric @ Feb 17 2007, 04:50 AM) 383999
Basically you want to compare your health/mana/ego/power etc to the prompt before it. This way you are using your previous's prompt's health and mana in your prevHealth prevMana variables. Then you do a check to see if your prevhealth is not your curhealth (a change). And etc: I think this works

CODE
#var prevHealth curHealth
#var prevMana curMana
#var curHealth %1
#var curMana %1

#if (@prevHeath!=@curHealth) {
  #math diffHealth (@curHealth-@prevHealth)
  #if (@diffhealth > 0) {
    #say "+"@diffhealth"h"
    } {
    #say @diffhealth"h"
    }
  }
}


Let me know how it works out (and if the zmud script is correct =p)

EDIT: Ahhh I see your sub is one line so you would have to do this as a function call hrm. What you could do is do this piece of script before your actual sub, and do the #if @diffhealth if statement as a function in there to figure out whether to display +xh, or leave it as -xh.


I like that, it is rather cute, though being honest, I would much rather have the sub do everything. harhar1.gif

Grabbed it though in case of stress levels hitting dire limits, heh.
relaren2007-02-17 08:31:26
OK, to avoid confusion owing to all the changes, here is the modified script.

CODE
#CLASS {Prompt Stuff}
#VAR health {}
#VAR maxhealth {}
#VAR endurance {}
#VAR maxendurance {}
#VAR mana {}
#VAR maxmana {}
#VAR willpower {}
#VAR maxwillpower {}
#VAR ego {}
#VAR maxego {}
#VAR power {}
#VAR stats {}
#VAR hchange %eval( @health - %1)
#VAR mchange %eval( @mana - %2)
#VAR echange %eval( @ego - %3)
#ALIAS trig {#if (%1 = off) {#t- "ptrig"} {#t+ "ptrig"}}
#REGEX {^(\\d+)h, (\\d+)m, (\\d+)e, (\\d+)p, (\\d+)en, (\\d+)w (+)$} {health=%1;mana=%2;ego=%3;power=%4;endurance=%5;willpower=%6;stats=%7;#variable healthperc %eval( %float( @health)/@maxhealth*100);#variable manaperc %eval( %float( @mana)/@maxmana*100);#variable egoperc %eval( %float( @ego)/@maxego*100);#substitute {%ansi(grey)~<%if( @healthperc >= 60, %ansi( green), "")%if( @healthperc >= 30 and @healthperc < 60, %ansi( high, yellow), "")%if( @healthperc < 30, %ansi( high, red), "")@health~/%ansi(green)@maxhealth %if( @manaperc >= 60, %ansi( green), "")%if( @manaperc >= 30 and @manaperc < 60, %ansi( high, yellow), "")%if( @manaperc < 30, %ansi( high, red), "")@mana/%ansi(green)@maxmana %if( @egoperc >= 60, %ansi( green), "")%if( @egoperc >= 30 and @egoperc < 60, %ansi( high, yellow), "")%if( @egoperc < 30, %ansi( high, red), "")@ego/%ansi(green)@maxego%ansi(yellow) @power @endurance @willpower%ansi(grey)~> %ansi(green)~(%ansi(high,red)@stats%ansi(green)~) %ansi(high,red)~}} "Prompt Stuff"
#REGEX {Health : (\\d+)/(\\d+)} {health=%1;maxhealth=%2} "Prompt Stuff"
#REGEX {Endurance : (\\d+)/(\\d+)} {endurance=%1;maxendurance=%2} "Prompt Stuff"
#REGEX {Mana   : (\\d+)/(\\d+)} {mana=%1;maxmana=%2} "Prompt Stuff"
#REGEX {Willpower : (\\d+)/(\\d+)} {willpower=%1;maxwillpower=%2} "Prompt Stuff"
#REGEX {Ego    : (\\d+)/(\\d+)} {ego=%1;maxego=%2} "Prompt Stuff"
#CLASS 0

Unknown2007-02-17 11:58:12
Your change variables are calculated only once. You need to calculate them each time a prompt fires your trigger, and you need to do it before saving the current values.
Laysus2007-02-17 21:45:20
Should be #function instead of #var for the change variables, is all, I think.
Unknown2007-02-18 13:05:09
Changing from #VAR to #FUNC might help, if the old values weren't discarded before the new ones were saved. As it was last posted, the change variables aren't used in the output stuff now, anyway.
relaren2007-02-18 13:59:58
I do apologise, I am not sure why the variables are even declared there. Very odd.
Well, I am a step further with this, although it is not totally working, and being as early as it is, my head just wont work just yet.

Any further help is of course appreciated.

Basically with this here, I have it displaying though not correctly. When I gain HP for example, it is showing as -x. What am I doing wrong?

CODE
health=%1
mana=%2
ego=%3
power=%4
endurance=%5
willpower=%6
stats=%7
diagnose=0
#if (%pos( 'e', %7)) {#variable equilibrium 1} {#variable equilibrium 0}
#if (%pos( 'x', %7)) {#variable balance 1} {#variable balance 0}
#if (%pos( 'b', %7)) {#variable blind 1} {#variable blind 0}
#if (%pos( 'd', %7)) {#variable deaf 1} {#variable deaf 0}
#if (%pos( 'k', %7)) {#variable insomnia 1} {#variable insomnia 0}
#if (%pos( 's', %7)) {#variable substratus 1} {#variable substratus 0}
#if (%pos( 'S', %7)) {#variable superstratus 1} {#variable superstratus 0}
#if (%pos( 'i', %7)) {#variable id_psi 1} {#variable id_psi 0}
#if (%pos( 'p', %7)) {#variable prone 1} {#variable prone 0}
#if (@prone=1 AND @webbed=0 AND @meditating=0 AND @asleep=0 AND @aeon=0 AND @balance=1 AND @equilibrium=1) {stand}
sipcheck
vlockcheck
salveheal
herbcheck
aeoncheck
purgeheal
#variable hchange %eval( @health - @healthstore)
#variable mchange %eval( @mana - @manastore)
#variable echange %eval( @ego - @egostore)
healthstore=@health
manastore=@mana
egostore=@ego
#variable healthperc %eval( %float( @health)/@maxhealth*100)
#variable manaperc %eval( %float( @mana)/@maxmana*100)
#variable egoperc %eval( %float( @ego)/@maxego*100)
#substitute {%ansi(grey)~<%if( @healthperc >= 60, %ansi( green), "")%if( @healthperc >= 30 and @healthperc < 60, %ansi( high, yellow), "")%if( @healthperc < 30, %ansi( high, red), "")@health~/%ansi(green)@maxhealth%if( @hchange < 0 and !%null(@hchange), ~ ~+%abs(@hchange))%if( @hchange > 0 and !%null(@hchange), ~ ~-@hchange) %if( @manaperc >= 60, %ansi( green), "")%if( @manaperc >= 30 and @manaperc < 60, %ansi( high, yellow), "")%if( @manaperc < 30, %ansi( high, red), "")@mana/%ansi(green)@maxmana%if( @mchange < 0 and !%null(@mchange), ~ ~+%abs(@mchange))%if( @mchange > 0 and !%null(@mchange), ~ ~-@mchange) %if( @egoperc >= 60, %ansi( green), "")%if( @egoperc >= 30 and @egoperc < 60, %ansi( high, yellow), "")%if( @egoperc < 30, %ansi( high, red), "")@ego/%ansi(green)@maxego%if( @echange < 0 and !%null(@echange), ~ ~+%abs(@echange))%if( @echange > 0 and !%null(@echange), ~ ~-@echange)%ansi(yellow) @power @endurance @willpower%ansi(grey)~> %ansi(green)~(%ansi(high,red)@stats%ansi(green)~) %ansi(high,red)~}


Oh yes, Zarquan, if you end up reading this. What do we have similar to a mindseye here, please? I am getting tired of getting blind and deaf then just healing it sad.gif Many thanks.

EDIT: Forgot to mention, but as for changing them to functions, that surprisingly breaks the computations completely, so something is certainly amiss.
Unknown2007-02-18 16:14:22
We have sixth sense (eat faeleaf) and true hearing (eat earwort) which essentially separate the mindseye into two separate parts. You only need to cure blindness and deafness if you don't have the sixth sense and/or true hearing.

The functions would be used in a different way, but what you have should work to give you the same result. Six in one, half dozen in the other.

You have your + and - for the echo backwards, by the way.
relaren2007-02-18 17:59:37
QUOTE(Zarquan @ Feb 18 2007, 04:14 PM) 384401
You have your + and - for the echo backwards, by the way.


I will just go and crawl into my little corner now. sad.gif

Thankyou dearly for pointing out that majorly obvious error. In my defence, I did say it was morning. Heh.

Regards once again.
relaren2007-02-18 18:20:37
OK, for the sake of continuity, here is the final working script. Enjoy!

CODE
#CLASS {Prompt Stuff}
#VAR health {}
#VAR maxhealth {}
#VAR endurance {}
#VAR maxendurance {}
#VAR mana {}
#VAR maxmana {}
#VAR willpower {}
#VAR maxwillpower {}
#VAR ego {}
#VAR maxego {}
#VAR power {}
#VAR stats {}
#ALIAS trig {#if (%1 = off) {#t- "ptrig"} {#t+ "ptrig"}}
#REGEX "ptrig" {^(\\d+)h, (\\d+)m, (\\d+)e, (\\d+)p, (\\d+)en, (\\d+)w (+)$} {health=%1;mana=%2;ego=%3;power=%4;endurance=%5;willpower=%6;stats=%7;diagnose=0;#if (%pos( 'e', %7)) {#variable equilibrium 1} {#variable equilibrium 0};#if (%pos( 'x', %7)) {#variable balance 1} {#variable balance 0};#if (%pos( 'b', %7)) {#variable blind 1} {#variable blind 0};#if (%pos( 'd', %7)) {#variable deaf 1} {#variable deaf 0};#if (%pos( 'k', %7)) {#variable insomnia 1} {#variable insomnia 0};#if (%pos( 's', %7)) {#variable substratus 1} {#variable substratus 0};#if (%pos( 'S', %7)) {#variable superstratus 1} {#variable superstratus 0};#if (%pos( 'i', %7)) {#variable id_psi 1} {#variable id_psi 0};#if (%pos( 'p', %7)) {#variable prone 1} {#variable prone 0};#if (@prone=1 AND @webbed=0 AND @meditating=0 AND @asleep=0 AND @aeon=0 AND @balance=1 AND @equilibrium=1) {stand};sipcheck;#variable hchange %eval( @health - @healthstore);#variable mchange %eval( @mana - @manastore);#variable echange %eval( @ego - @egostore);healthstore=@health;manastore=@mana;egostore=@ego;#variable healthperc %eval( %float( @health)/@maxhealth*100);#variable manaperc %eval( %float( @mana)/@maxmana*100);#variable egoperc %eval( %float( @ego)/@maxego*100);#substitute {%ansi(grey)~<%if( @healthperc >= 60, %ansi( green), "")%if( @healthperc >= 30 and @healthperc < 60, %ansi( high, yellow), "")%if( @healthperc < 30, %ansi( high, red), "")@health~/%ansi(green)@maxhealth%if( @hchange < 0 and !%null(@hchange), ~ ~-%abs(@hchange))%if( @hchange > 0 and !%null(@hchange), ~ ~+@hchange) %if( @manaperc >= 60, %ansi( green), "")%if( @manaperc >= 30 and @manaperc < 60, %ansi( high, yellow), "")%if( @manaperc < 30, %ansi( high, red), "")@mana/%ansi(green)@maxmana%if( @mchange < 0 and !%null(@mchange), ~ ~-%abs(@mchange))%if( @mchange > 0 and !%null(@mchange), ~ ~+@mchange) %if( @egoperc >= 60, %ansi( green), "")%if( @egoperc >= 30 and @egoperc < 60, %ansi( high, yellow), "")%if( @egoperc < 30, %ansi( high, red), "")@ego/%ansi(green)@maxego%if( @echange < 0 and !%null(@echange), ~ ~-%abs(@echange))%if( @echange > 0 and !%null(@echange), ~ ~+@echange)%ansi(yellow) @power @endurance @willpower%ansi(grey)~> %ansi(green)~(%ansi(high,red)@stats%ansi(green)~) %ansi(high,red)~}} "Prompt Stuff"
#REGEX {Health : (\\d+)/(\\d+)} {health=%1;maxhealth=%2} "Prompt Stuff"
#REGEX {Endurance : (\\d+)/(\\d+)} {endurance=%1;maxendurance=%2} "Prompt Stuff"
#REGEX {Mana   : (\\d+)/(\\d+)} {mana=%1;maxmana=%2} "Prompt Stuff"
#REGEX {Willpower : (\\d+)/(\\d+)} {willpower=%1;maxwillpower=%2} "Prompt Stuff"
#REGEX {Ego    : (\\d+)/(\\d+)} {ego=%1;maxego=%2} "Prompt Stuff"
#CLASS 0