[TF] An odd request
Brought to you by:
kenkeys
|
From: phil.pennock at globnix.o. (P. Pennock) - 2003-04-03 15:28:20
|
On 2003-04-02 at 17:12 -0600, Mark Rogo wrote:
> For reasons that probably relate too closely to silliness and
> boredom I have been trying to create a status line that would act like a
> ticker tape. Scrolling a message across it from right to left.
>
> Has anyone else attempted this? The way I have tried doesn't
> really work the way I had expected it too, (and is incredibly messy). If
> anyone would care to give it a go I would appreciate it. And of course if
> you just want to call me 'odd' that works too.
I hadn't tried it before, but I'd not written any tf scripts in so long,
that I decided to give it a go. :^)
Try loading the script below. Use /ticker to change the ticker at any
time, eg:
/ticker Supercalifragilisticexpialidocious
I tried googling for a reminder of how to set a string with trailing
whitespace, but failed to find something (only stuff about how Tf strips
trailing whitespace). I know it can be done, but I forget how, so I
ended up ducking the issue by just using __ as a trailing bit of string.
Note that from the moment the file is loaded, there's a ticker running,
it just happens to continually display "___" in a field 20 chars wide,
padding with "_". :^) /PS and /KILL are your friends if you want to
stop the ticker, and just run /ticker_update once to restart it.
You can simplify /ticker_update a lot if you are willing to have the
entire string scroll off before starting again.
Works For Me (TM).
-Phil
-----------------------------< cut here >-------------------------------
; How much of the string should be shown at once;
; if you change this, you need to set status_fields again
/set ticker_show_len 20
; How often to update the ticker; can change dynamically
/set ticker_repeat 2
; Set a new ticker string
/def ticker = \
/set ticker_str=$[strcat({1}, "__")] %;\
/set ticker_len $[strlen({ticker_str})] %;\
/set ticker_offset 0 %;\
/set ticker_show $[substr(ticker_str, 0, ticker_show_len)]
; The function that will update the ticker
/def ticker_update = /set ticker_offset=$[{ticker_offset} + 1] %;\
/if (ticker_offset > {ticker_len}) /set ticker_offset=0 %; /endif %;\
/let start=$[substr(ticker_str, ticker_offset, ticker_show_len)] %;\
/if (strlen(start) < ticker_show_len) \
/let tail=$[substr(ticker_str, 0, (ticker_len - strlen(start)))] %;\
/set ticker_show $[strcat(start, tail)] %;\
/else \
/set ticker_show %start %;\
/endif %;\
/repeat -%ticker_repeat 1 /ticker_update
; These two are initialisation;
; (need at least ticker_show defined before setting status_fields)
/ticker _
/ticker_update
; This is an example status_fields using the ticker
; The /eval is simply to get the length substituted
/eval /set status_fields :1 @world :1 ticker_show:%{ticker_show_len} :1
|