alias hint {
set %answer $2-
var %b = $regsub($2-,/([[:alnum:]])/g,_,%hint)
.timerHint 3 5 MakeHint $1
}
alias MakeHint {
set %hint $scatter($1,%hint)
echo -a Hint: %hint
}
alias scatter {
var %n = $int($calc($regex(%answer,/([[:alnum:]])/g)*($1 / 100))), %h = $2-, %k
if ($count(%h,_) <= %n) { return %answer }
while (%n) {
while ($mid(%h,%k,1) != _) { %k = $r(1,$len(%h)) }
%h = $+($left(%h,$calc(%k - 1)),$mid(%answer,%k,1),$right(%h,$calc(-1 * %k)))
dec %n
}
return %h
}
Original Scatter alias from tatarize altered to only scramble what's left after the hint before.
usage:
/hint <% visibele after each hint> <answer>
example:
/hint 25 this is a Hint-test
will return:
Hint: _h_s _s _ ____-____
Hint: th_s _s a __n_-____
Hint: th_s _s a H_n_-__st
Timer is set to 3 hints every 5 seconds.
The code:
if ($count(%h,_) <= %n) { return %answer }
will prevent an infinite loop if % is above 100; so choose the number of hints and percentage wisely
One remark:
The percentage can be one letter down each hint because of the usage of $int().