I've seen some REALLY complicated rainbow scripts out there, and I don't know why people need to make such mindless fun so complicated. I just decided to make a fun input script to randomly generate rainbow text.
menu * {
$iif(%rainbows == on,Turn Rainbows Off,Turn Rainbows on) : $iif(%rainbows == on,unset %rainbows,set %rainbows on)
}
on *:input:*: {
if ($left($1-,1) != / && %rainbows == on) {
haltdef
set -l %count 1
while (%count <= $len($1-)) {
set -l %rainbow %rainbow $+ $+ $gettok(04.07.08.09.11.13,$r(1,6),46) $+ ,01 $+ $iif($mid($1-,%count,1) != $chr(32),$mid($1-,%count,1),$chr(32) $+ $chr(32))
inc %count
}
msg $active %rainbow
}
}
Jethro_ wrote:
whatever to each their own
[quote]That's your enduring signature, isn't it? lol[/quote]
lol well they can use whatever they want. I am not forcing them to do it the way my example is. That is why I said " Example using groups with keeping your code the same" just with the group instead of the global var. ;x
also [size=14]To each their own[/size] [size=20]=P[/size]
And if you may, make regsub() functon the same as this snippet intends.
$regsub() is not supposed to function that way. $regsubex() was added specifically for cases where the substitutions need to be made before the substitution parameter is evaluated, which is what that method calls for. in all other cases, we should (but often don't) use $regsub().
GoldFish on your menu I wouldn't go with menu * as it can get messy if you have picwins an such just put in where you want to turn it off an on. imho i would use groups for the on an off
Example using groups with keeping your code the same:
menu menubar,channel,query {
Turn Rainbow $iif($group(#rainbow) = on,Off,On):$+(.,$iif($group(#rainbow) = on,dis,en),able) #rainbow
}
#rainbow off
on *:input:*: {
if ($left($1-,1) != /) {
haltdef
set -l %count 1
while (%count <= $len($1-)) {
set -l %rainbow %rainbow $+ $+ $gettok(04.07.08.09.11.13,$r(1,6),46) $+ ,01 $+ $iif($mid($1-,%count,1) != $chr(32),$mid($1-,%count,1),$chr(32) $+ $chr(32))
inc %count
}
msg $active %rainbow
}
}
#rainbow end
but whatever to each their own...
I haven't heard that 6.16 doesn't support /var command yet. :/
You can add the -l switch, which will make your /set command as a local variable like so:> on :input:: {
if ($left($1-,1) != /) {
haltdef
set -l %count 1
while (%count <= $len($1-)) {
set -l %rainbow %rainbow $+ $+ $gettok(04.07.08.09.11.13,$r(1,6),46) $+ ,01 $+ $iif($mid($1-,%count,1) != $chr(32),$mid($1-,%count,1),$chr(32) $+ $chr(32))
inc %count
}
msg $active %rainbow
}
}the -l switch is undocumented but function the same as /var. With a local variable, you don't need to have it unset at the end.
I don't see using regsubex being complicated, do you?
on *:input:*:{
if ($left($1-,1) != /) {
say 0,1 $+ $regsubex($1-,/(.)/g,$+($chr(3),$gettok(04.07.08.09.11.13,$r(1,6),46),\1))
haltdef
}
}
However, the only drawback is that regsubex doesn't support older version below 6.17.
Nice work, though. GoldFish.
how come this comes in normal and then rainbow? someone help please