Prompt.tf
Jump to navigation
Jump to search
A prompt script. Values are grabbed, hp/mana/move/monitor are colored to reflect their status. Read the comments in the script for more information.
;Bug reports, suggestions and/or diffs are appreciated, '''sulfar''' _AT_ ''inbox'' +DOT+ ''com'' /loaded __SULFAR__/prompt.tf ;These are the prompts I set on the mud. ;prompt <%h/%H(%p) %m/%M(%o) %v/%V [%T] %w/%W(%P) t%s>%n ;prompt2 <s%S a%A q%Q>%n ;also type "prompt2" once or twice and make sure it's on since the trigger below ; gags it ;Prompt1 is substituted by substitute_prompt1. It adds values to see the loss ; in hp, mana and monitor's hp. It also changes the color of hp/mana/monitor. ; If hp is higher than 70% it's colored green, if it's between 30% and 70% it's ; colored yellow, if it's lower than 30% it's colored red. Moves are just ; green currently. ; ;To save space on the prompt line, I put tnl in tf's statusline as [320] for ; example. Tnl also shifts color, white if it's above 300, yellow for 300 or ; lower, bright yellow for 130 or lower. ;The AFK part of the prompt is captured but not displayed anywhere. ;prompt2 has values for surge, augment, quicken, is gagged and its values are ; captured to status_ variables to use in the tf status line. "Off" values ; are changed to "0" to save some space on the satusline. Surge, augment ; and quicken levels are not colored yet. ;I set my status line in a single command in my config file, this is what it ; looks like with the right variables for this script ;/status_add -c @more:8:Br :1 @world:9 :1 "s":1 status_surge:1 :1 "a":1 status_augment:1 :1 "q":1 status_quicken:1 :1 status_tnl:6 :1 insert:6 :1 @clock:16 ;If you'd like to use the script and the prompt setting above contains all the ; information you want but just doesn't look the way you want, I'd recommend ; setting it to the format above anyways and then change the substitute below ; to make it appear the way you want. ;set mud side prompt to be compatible with prompt.tf /def -i prompt_set= prompt <%%h/%%H(%%p) %%m/%%M(%%o) %%v/%%V [%%T] %%w/%%W(%%P) t%%s>%%n%;prompt2 <s%%S a%%A q%%Q>%%n ;Hooray for regexps! /def -i -F -p400 -mregexp -t"^(\$|)(\&|)(\<D\>|)(\[S\]|)(\!|)(\@|)(\#|)(\*Deaf\* |)(\(AFK\) |)<(-?[0-9]*)/(-?[0-9]*)\((-?[0-9]*)\%\) (-?[0-9]*)/(-?[0-9]*)\((-?[0-9]*)\%\) (-?[0-9]*)/(-?[0-9]*) \[(-?[0-9]*)\] (-?[0-9]*)/(-?[0-9]*)\((-?[0-9]*)\%?\) t([0-9]+)>" substitute_prompt1 =\ ;set prompt vars /set prompt_sanctuary %{P1}%;\ /set prompt_werrebocler %{P2}%;\ /set prompt_demonfire %{P3}%;\ /set prompt_stance %{P4}%;\ /set prompt_invis %{P5}%;\ /set prompt_move_hidden %{P6}%;\ /set prompt_sneak %{P7}%;\ /set prompt_deaf %{P8}%;\ /set prompt_afk %{P9}%;\ /test prompt_hp:=strip_attr({P10})%;\ /test prompt_hp_max:=strip_attr({P11})%;\ /test prompt_hp_relative:=strip_attr({P12})%;\ /test prompt_mana:=strip_attr({P13})%;\ /test prompt_mana_max:=strip_attr({P14})%;\ /test prompt_mana_relative:=strip_attr({P15})%;\ /test prompt_move:=strip_attr({P16})%;\ /test prompt_move_max:=strip_attr({P17})%;\ /test prompt_tnl:=strip_attr({P18})%;\ /test prompt_monitor:=strip_attr({P19})%;\ /test prompt_monitor_max:=strip_attr({P20})%;\ /test prompt_monitor_relative:=strip_attr({P21})%;\ /test prompt_lagtimer:=strip_attr({P22})%;\ /set prompt_hp_diff $[prompt_hp_max - prompt_hp]%;\ /set prompt_mana_diff $[prompt_mana_max - prompt_mana]%;\ /set prompt_monitor_diff -%;\ /test (prompt_monitor_max !~ "-") & (prompt_monitor_diff:=prompt_monitor_max - prompt_monitor)%;\ ;colorizing hp /if (prompt_hp_relative <= 30) \ /test (prompt_hp:=decode_attr(prompt_hp, "Cred"), \ prompt_hp_max:=decode_attr(prompt_hp_max, "Cred"), \ prompt_hp_diff:=decode_attr(prompt_hp_diff, "Cred"), \ prompt_hp_relative:=decode_attr(prompt_hp_relative, "Cred"))%;\ /elseif (prompt_hp_relative <= 70) \ /test (prompt_hp:=decode_attr(prompt_hp, "Cyellow"), \ prompt_hp_max:=decode_attr(prompt_hp_max, "Cyellow"), \ prompt_hp_diff:=decode_attr(prompt_hp_diff, "Cyellow"), \ prompt_hp_relative:=decode_attr(prompt_hp_relative, "Cyellow"))%;\ /else \ /test (prompt_hp:=decode_attr(prompt_hp, "Cgreen"), \ prompt_hp_max:=decode_attr(prompt_hp_max, "Cgreen"), \ prompt_hp_diff:=decode_attr(prompt_hp_diff, "Cgreen"), \ prompt_hp_relative:=decode_attr(prompt_hp_relative, "Cgreen"))%;\ /endif%;\ ;colorizing mana /if (prompt_mana_relative <= 30) \ /test (prompt_mana:=decode_attr(prompt_mana, "Cred"), \ prompt_mana_max:=decode_attr(prompt_mana_max, "Cred"), \ prompt_mana_diff:=decode_attr(prompt_mana_diff, "Cred"), \ prompt_mana_relative:=decode_attr(prompt_mana_relative, "Cred"))%;\ /elseif (prompt_mana_relative <= 70) \ /test (prompt_mana:=decode_attr(prompt_mana, "Cyellow"), \ prompt_mana_max:=decode_attr(prompt_mana_max, "Cyellow"), \ prompt_mana_diff:=decode_attr(prompt_mana_diff, "Cyellow"), \ prompt_mana_relative:=decode_attr(prompt_mana_relative, "Cyellow"))%;\ /else \ /test (prompt_mana:=decode_attr(prompt_mana, "Cgreen"), \ prompt_mana_max:=decode_attr(prompt_mana_max, "Cgreen"), \ prompt_mana_diff:=decode_attr(prompt_mana_diff, "Cgreen"), \ prompt_mana_relative:=decode_attr(prompt_mana_relative, "Cgreen"))%;\ /endif%;\ ;colorize monitor /if (prompt_monitor_relative <= 30) \ /test (prompt_monitor:=decode_attr(prompt_monitor, "Cred"), \ prompt_monitor_max:=decode_attr(prompt_monitor_max, "Cred"), \ prompt_monitor_diff:=decode_attr(prompt_monitor_diff, "Cred"), \ prompt_monitor_relative:=decode_attr(prompt_monitor_relative, "Cred"))%;\ /elseif (prompt_monitor_relative <= 70) \ /test (prompt_monitor:=decode_attr(prompt_monitor, "Cyellow"), \ prompt_monitor_max:=decode_attr(prompt_monitor_max, "Cyellow"), \ prompt_monitor_diff:=decode_attr(prompt_monitor_diff, "Cyellow"), \ prompt_monitor_relative:=decode_attr(prompt_monitor_relative, "Cyellow"))%;\ /else \ /test (prompt_monitor:=decode_attr(prompt_monitor, "Cgreen"), \ prompt_monitor_max:=decode_attr(prompt_monitor_max, "Cgreen"), \ prompt_monitor_diff:=decode_attr(prompt_monitor_diff, "Cgreen"), \ prompt_monitor_relative:=decode_attr(prompt_monitor_relative, "Cgreen"))%;\ /endif%;\ ;colorize mv /test (prompt_move:=decode_attr(prompt_move, "Cgreen"), \ prompt_move_max:=decode_attr(prompt_move_max, "Cgreen"))%;\ ;colorize tnl /if ((prompt_tnl <= 300) & (prompt_tnl > 130)) /set prompt_tnl $[decode_attr(prompt_tnl, "Cyellow")]%;\ /elseif (prompt_tnl <= 130) /set prompt_tnl $[decode_attr(prompt_tnl, "BCyellow")]%;\ /else /set prompt_tnl $[decode_attr(prompt_tnl, "Cwhite")]%;\ /endif%;\ ;for the status line /set status_tnl [%{prompt_tnl}]%;\ ;colorize lagtimer /test prompt_lagtimer:=decode_attr(prompt_lagtimer, "Cgreen")%;\ ;finally, the substitute /substitute -aCrgb010 \ ;sanc,werrebocler,demonfire,stance,invis,mh,sneak,deaf %{prompt_sanctuary}%{prompt_werrebocler}%{prompt_demonfire}\ %{prompt_stance}%{prompt_invis}%{prompt_move_hidden}%{prompt_sneak}\ %{prompt_deaf}\ ;hp/max_hp(hp_diff/relative_hp) <%{prompt_hp}/%{prompt_hp_max}(%{prompt_hp_diff}|%{prompt_hp_relative}%%) \ ;mana/max_mana(relative_mana) %{prompt_mana}/%{prompt_mana_max}(%{prompt_mana_diff}|%{prompt_mana_relative}%%) \ ;move/max_move %{prompt_move}/%{prompt_move_max} \ ; ;[tnl] -- uncomment the next line to restore tnl to the prompt you see ; [%{prompt_tnl}] \ ; ;monitor/max_monitor(monitor_diff/monitor_relative)) %{prompt_monitor}/%{prompt_monitor_max}(%{prompt_monitor_diff}|%{prompt_monitor_relative}%%) \ ;lag timer t%{prompt_lagtimer}\ > ;Grab prompt2 and set the status line variables /def -i -ag -F -p400 -mregexp -t"<s([^ ]+) a([^ ]+) q([^ ]+)>" substitute_prompt2 =\ /test status_surge:=strip_attr({P1})%;\ /test status_augment:=strip_attr({P2})%;\ /test status_quicken:=strip_attr({P3})%;\ /test (status_surge =~ "off") & (status_surge:=0)%;\ /test (status_augment =~ "off") & (status_augment:=0)%;\ /test (status_quicken =~ "off") & (status_quicken:=0)