[TF] Re: Status line variables
Brought to you by:
kenkeys
|
From: phil_g at pobox.c. (P. Gregory) - 2003-03-12 16:49:48
|
* Mark Rogo <ma...@ma...> [2003-03-11 14:20 -0600]:
> The other thing is based my percentage of HP left I'd like the color to
> change. Basically the same thing. I'm guessing I haven't quite mastered
> most of the /if stuff. Any help would be great!
I do this with my status line (and tinyfugue compiled from tf-macros CVS).
It's basically just a bunch of /if statements. Excerpted from my
status.tf:
; Pull all of the vaules out of the prompt. All prompt variables start
; with pr_.
;
; Example:
; 179/250h 182/182m 130/213e 752x 94 (278)>
/def -p1000 -mregexp -ag -h'PROMPT ([-+0-9]+)/([-+0-9]+)h ([-+0-9]+)/([-+0-9]+)m ([-+0-9]+)/([-+0-9]+)e ([-+0-9]+)x ([-+0-9]+) \(([-+0-9]+)\)> ' prompt1 =\
/set pr_hpcur=%P1%; /set pr_hpmax=%P2%; /set pr_spcur=%P3%;\
/set pr_spmax=%P4%; /set pr_epcur=%P5%; /set pr_epmax=%P6%;\
/set pr_exp=%P7%; /set pr_gold=%P8%; /set pr_bank=%P9%;\
/check_stats%;\
/prompt *>
; Does all of the calculations on the prompt data for display in the
; status line.
/def check_stats = \
/set pr_hpdif=$[{pr_hpcur}-{pr_old_hpcur}]%;\
; [same for sp and ep]
/set st_exp=%pr_exp%;\
/set pr_old_hpcur=%pr_hpcur%;
; [same for sp and ep]
/set st_hpcur=$[pad(pr_hpcur, 4)]%;/set st_hpmax=$[pad(pr_hpmax, -4)]%;\
; [same for sp and ep]
/if (pr_hpdif!=0 | pr_spdif!=0 | pr_epdif!=0) \
/set st_hpreg=$[pad(pr_hpdif, 4)]%;\
; [same for sp and ep]
/set st_hpcolor=$[status_changecolor(pr_hpcur, pr_hpmax, pr_hpdif)]%;\
; [same for sp and ep]
/set ticktime_t=$[time()-ticktime]%;\
/set ticktime=$[time()]%;\
/echo -p * @{%{st_hpcolor}}%{pr_hpdif}@{n}hp @{%{st_spcolor}}%{pr_spdif}@{n}sp \
@{%{st_epcolor}}%{pr_epdif}@{n}ep in @{Cyellow}%{ticktime_t}@{n}s%;\
/endif%;\
/set st_hpcurcolor=$[status_damcolor(st_hpcur, st_hpmax)]%;\
/set st_hpmaxcolor=$[status_maxcolor(st_hpcur, st_hpmax)]%;\
; [same for sp and ep]
/statusset
; The bit you're mostly interested in.
/def status_damcolor = \
/if (%2!=0) \
/set percent=$[100 * %1 / %2]%;\
/if (percent > 100) /result 'rBCgreen'%;\
/elseif (percent >= 90) /result 'rCgreen' %;\
/elseif (percent >= 80) /result 'BCgreen' %;\
/elseif (percent >= 65) /result 'Cgreen' %;\
/elseif (percent >= 50) /result 'Cyellow' %;\
/elseif (percent >= 35) /result 'BCyellow'%;\
/elseif (percent >= 20) /result 'Cred' %;\
/elseif (percent >= 10) /result 'BCred' %;\
/elseif (percent >= 00) /result 'rCred' %;\
/else /result 'rBCred' %;\
/endif%;\
/endif
; If my points are at or above their max value, the max is shown in
; reverse, too.
/def status_maxcolor = \
/if (%1>=%2) /result 'rCgreen'%; /else /result 'B'%; /endif
; And the prompt itself.
/def -ag -h'SEND {statusset}' statusset = /set status_fields= \
st_hpcur:4:%{st_hpcurcolor} "/"::%{st_hpmaxcolor} st_hpmax:4:%{st_hpmaxcolor} "(" st_hpreg:4:%{st_hpcolor} ")" :1 \
st_spcur:4:%{st_spcurcolor} "/"::%{st_spmaxcolor} st_spmax:4:%{st_spmaxcolor} "(" st_spreg:4:%{st_spcolor} ")" :1 \
st_epcur:4:%{st_epcurcolor} "/"::%{st_epmaxcolor} st_epmax:3:%{st_epmaxcolor} "(" st_epreg:4:%{st_epcolor} ")" :1 \
"Xp:" st_exp::Cyellow :1 @log:3
--
ph...@po... / phil! / DNRC / http://aperiodic.net/phil/
PGP: ID: D8C75CF5 print: 0A7D B3AD 2D10 1099 7649 AB64 04C2 05A6
--- --
Never tell people how to do things. Tell them WHAT to do and they will
surprise you with their ingenuity.
-- Gen. George S. Patton, Jr.
---- --- --
|