Status console - tf

Text:


; ..:....1....:....2....:....3....:....4....:....5....:....6....:....7....:...
;
; Cleaning up after the party, we have this functional script.
;
; apparently, tf restricts status_height to <= 6. so, we use that.
; (discovered by Javelin)
;
/set status_height=6
;
; ..:....1....:....2....:....3....:....4....:....5....:....6....:....7....:...
; Now, we trigger on receiving data matching
;
; !<TFPREFIX>C<n> <data>
;
; (where TFPREFIX is a secret set by each user, and 'C' is the
; 'CONSOLE' identifier for tf)
;
; since TFPREFIX isn't actually required for this, I suggest using
; something else altogether, so as to separate the protocol entirely
; from @dec/tf.
; -hack
;
; and then display data on line n (from 0-6), replacing anything
; already on that line.
;
/for r 1 4 /status_add -c -r%{r} data_%{r}:$[columns()]
/for r 1 4 /set data_%{r}=$[pad(" ",-columns())]
/def -ag -mregexp -t'!TFPREFIXC(\d+) (.*)' statstuff = \
  /set data_%P1=$[pad({P2},-columns())]
;
; (this section written by Javelin)
; ..:....1....:....2....:....3....:....4....:....5....:....6....:....7....:...
; The protocol has been extended to support placing a string at
; row X, column Y (where the first column is 0), making this optional method
; take the format
;
; !<TFPREFIX>C<Row#>,<Col#> <data>
;
; the data can be a string and it will be placed into position as though
; typed in in 'typeover' mode (i.e., without modifying any of the surrounding
; text).
;
/def -ag -mregexp -t'!TFPREFIXC(\d+),(\d+) (.+)' statstuffbychar = \
/set dataname=data_%P1 %; \
/eval /set old_data=%%{%{dataname}} %; \
/set newlen=$[strlen(%P3)] %; \
/set data_%P1=$[strcat(substr({old_data}, 0, {P2}), {P3}, substr({old_data}, {P2}+{newlen}, columns()))]
;
; (this section drafted by Javelin and debugged by Trispis)
;
; NOTE: The above code potentially can
; overwrite any data_# tf variable.
; If more protection is needed,
; the first (\d+) in the trigger
; pattern could be changed to
; ([1-5]) or something. - Jav
; ..:....1....:....2....:....3....:....4....:....5....:....6....:....7....:...
; Things left to do:
; Make it world-aware -- console only being visible when toggled to
; the world feeding it. This means different consoles for different
; worlds.
; Make it go away when not in use.
; Make cool stuff to use it.