rendered paste bodyalias tslinky {
if ($1- === off) {
titlebar
.timerslinky off
}
else {
.slinky $replace($1-, $chr(32), $chr(160))
hdel slinky $hget(slinky, 0).item
.timerslinky -om 1 124 i-tslinky 1
}
}
alias -l i-tslinky {
if ($1 >= $hget(slinky, 0).item) .timerslinky -om 1 124 i-tslinky 1
else .timerslinky -om 1 124 i-tslinky $calc($1 + 1)
titlebar $hget(slinky, $1)
}
; Usage: /slinky <text>
; Fills a hashtable with slinky-effect'd text, then displays it.
; For internal use only, but it may be useful to generate a
; slinky elsewhere.
alias slinky {
if ($len($1-) == 0) return
hfree slinky
:error
reseterror
hmake slinky $calc($len($1-) * 10)
var %step 0, %maxspaces $ceil($calc($len($1-) / 2))
var %numsteps = $calc($len($1-) * 2 - $iif(2 // $len($1-), 1))
var %chars = $calc($len($1-) + %maxspaces * 2 - 1), %minchar = $calc(-(%maxspaces - 1) * 2)
; A-slinky from the riiiiight! And a-slinky from the leeeeeft!
while (%step < %numsteps) {
var %slinkystart $len($1-) - %step, %char %minchar, %spaces 1, %result, %action inc
while (%char <= %chars) {
if (%char > 0) && (%char <= $len($1-)) %result = %result $+ $mid($1-, %char, 1)
if (%char >= %slinkystart) && (%spaces >= 0) {
%result = %result $+ $str($chr(160), %spaces)
if (%spaces == %maxspaces) %action = dec
%action %spaces
}
inc %char
}
inc %step
hadd slinky %step %result
}
; Then reverse moves up and we'll slinky to the leeeeeft!
var %prevstep %step
while (%prevstep >= 1) { hadd slinky %step $hget(slinky, %prevstep) | inc %step | dec %prevstep }
; -- Display the slinky effect (the two lines below can be removed) --
%step = 1
while ($hget(slinky, %step)) { echo -aqng $hget(slinky, %step) | inc %step }
; -- End of display --
}