Rainbow Colors

By GoldFish on Aug 09, 2011

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
  }
}

Comments

Sign in to comment.
GoldFish   -  Aug 15, 2011

I actually do know $regex. I probably know how to use $regsub because it's the same syntax, I've just never worked with it.

 Respond  
napa182   -  Aug 11, 2011

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]

 Respond  
Jethro   -  Aug 11, 2011

Thank you, jaytea. I always thought they shared some sort of similarity but evidently not quite the case.

 Respond  
jaytea   -  Aug 11, 2011

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().

 Respond  
Jethro   -  Aug 11, 2011

whatever to each their ownThat's your enduring signature, isn't it? lol

 Respond  
napa182   -  Aug 11, 2011

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...

dma  -  Apr 06, 2018

how come this comes in normal and then rainbow? someone help please

Sign in to comment

Jethro   -  Aug 11, 2011

jaytea, would you mind to explain the apples and oranges? And if you may, make regsub() functon the same as this snippet intends. This should benefit people who have them discombobulated to begin with.

 Respond  
jaytea   -  Aug 11, 2011

Even without updating, you still have $regsub.

$regsub() is not the same as $regsubex() :P

 Respond  
Jethro   -  Aug 11, 2011

That's true, Gummo, but I suppose GoldFish doesn't know about it either.

 Respond  
Gummo   -  Aug 11, 2011

Even without updating, you still have $regsub.

 Respond  
napa182   -  Aug 09, 2011

GoldFish wrote:

I really should update, but I guess this is the best I can do with 6.16 :|

Um yeah you should really update to a newer version of mIRC. As 6.16 came out back in 2004 an they have updated it about 14 times so you are missing out on a lot that mIRC can do now.
newest version is 7.19

 Respond  
GoldFish   -  Aug 09, 2011

never heard of set -l, but it worked so cool. Thanks!

I updated the snippet with some of the suggestions

 Respond  
Jethro   -  Aug 09, 2011

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.

 Respond  
GoldFish   -  Aug 09, 2011

yeah I don't use $regsubex because I'm using 6.16
which also doesn't support /var...
or unset %var %var

I really should update, but I guess this is the best I can do with 6.16 :|

 Respond  
napa182   -  Aug 09, 2011

They should also incorporate an on an off function for this snippet.
5/10
anyways keep at it GoldFish.

 Respond  
Jethro   -  Aug 09, 2011

Yes I second that. The example above will serve as an example for people to choose from if they ever come across this snippet.

 Respond  
napa182   -  Aug 09, 2011

Jethro_ wrote:

I don't see using regsubex being complicated, do you?

Jethro_ I think they do cause they don't understand it yet. So they tend to call it complicated.

 Respond  
Jethro   -  Aug 09, 2011

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.

 Respond  
napa182   -  Aug 09, 2011

you should really switch your global vars into local vars, then no need for the unset. If you want to keep the global vars for some strange reason you can unset both vars on the same unset line
ie:

unset %rainbow %count
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.