|
Joined: Apr 2006
Posts: 400
Fjord artisan
|
OP
Fjord artisan
Joined: Apr 2006
Posts: 400 |
Ok guys, some of you all know I can script here, but, for some reason I can't get this script to work, I was wondering if someone could either help me with one or make it, and, i'll perfect it, it doesn't have to be good, at least some ideas would be good on how to make it. (Not saying "use while loops" :P ) -------------------- Here's what I'm trying to do /mix 2-4 This is an example.
This would come up: Basically, every odd number will be colour code 2, and, every even number will be colour code 4. Please help or give ideas. -In the meantime, I'll try and work on it, if I find the solution, I'll post again. Note: I'm guessing I can use tokens? Thanks!
Last edited by Kurdish_Assass1n; 05/02/07 10:01 PM.
-Kurdish_Assass1n
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
alias mix {
if ($0 < 2) {
echo -abc info * /mix: Insufficient parameters
return
}
if ($gettok($1,1,45) !isnum 0-15) || ($gettok($1,2,45) !isnum 0-15) {
echo -abc info * /mix: Invalid parameters
return
}
var %colour1 = $base($gettok($1,1,45),10,10,2), %colour2 = $base($gettok($1,2,45),10,10,2), %ctoken = 1, %token, %result
while ($gettok($2-,%ctoken,32)) {
%token = $v1
if (2 \\ %ctoken) { %result = $+(%result $chr(3),%colour1,%token,$chr(3)) }
else { %result = $+(%result $chr(3),%colour2,%token,$chr(3)) }
inc %ctoken
}
echo -a %result
}
This loops through each token using an iterator variable (%ctoken). With each iteration, it checks if %ctoken is not a multiple of (\\) 2, and if so it colours it the first colour you specify, otherwise it colours it the second colour you specify.
|
|
|
|
Joined: Apr 2006
Posts: 400
Fjord artisan
|
OP
Fjord artisan
Joined: Apr 2006
Posts: 400 |
lol, that was quick hixxy, thank you, I tried it and it worked better than I would have even thought about doing, thank you.
-Kurdish_Assass1n
|
|
|
|
Joined: Apr 2006
Posts: 400
Fjord artisan
|
OP
Fjord artisan
Joined: Apr 2006
Posts: 400 |
ok hixxy, i have a question, I don't see how you did this, I don't see any <CTRL + K> symbol in there, was it the "$chr(3)" or the "$base" ? I have never seen or used it before, I don't only want the script, I want to be able to learn it and know how it works, !
Last edited by Kurdish_Assass1n; 05/02/07 10:38 PM.
-Kurdish_Assass1n
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
The $chr(3) is a colour code.
The $base part is just there to make sure that both colour codes are translated into double digit codes, so if you do: /mix 1-3 blah, the script will interpret it as if you did /mix 01-03 blah. This is so that numbers in the text are not interpreted as parts of the colour code.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
That's a great way of getting colors into double digit format!! I've made other less efficient ways of doing it, but using $base like that is perfect.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Apr 2006
Posts: 400
Fjord artisan
|
OP
Fjord artisan
Joined: Apr 2006
Posts: 400 |
ok, one more question, sry, trying to understand this:
$base($gettok($1,1,45),10,10,2),
what's that and what are the numbers? I know gettok, but, not $base, I tried looking at the help file, but, didn't understand it, Please try and explain if you can, Thanks.
-Kurdish_Assass1n
|
|
|
|
Joined: Jan 2007
Posts: 259
Fjord artisan
|
Fjord artisan
Joined: Jan 2007
Posts: 259 |
I belive the first number is the "in type" whereas 0-10 = decimal (10), 0-1 = binairy (2) for example: $base(123,10,2) should return a mixture of 1's and 0s (don't have time to test it :P). $base(1,10,10,3) would return 001 (the ,3 at the end is the zeropad, it forces the digit to be X numbers long, minimum, and adds '0's to the front to make sure its as long as you specify)
Hope my messy comment helps :P
Those who can, cannot. Those who cannot, can.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Yes, the first number (the $gettok part) is the input number. The second number (the first 10) is the base that the input number is in. Base 10 is what we usually use. Hexadecimal is Base 16, Octal is Base 8, and Binary is Base 2 to name a few. Second third number (second 10) is what you're converting the number to. So, we're "converting" a Base 10 number to a Base 10 number (in other words, we're not changing it at all). Then, the final number is the minimum length of the number. Because it's 2, the number will always be at least 2 digits.
$base(1,10,10,2) = 01 $base(100,10,10,2) = 100
Notice on the second one that it's unchanged because the input number is longer than the minimum length, so no changes are necessary.
For actual conversions, you'd see something like:
$base(2,10,2,2) = 10
For that, 2 in decimal (Base 10) format is 10 in binary (Base 2) format.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Apr 2006
Posts: 400
Fjord artisan
|
OP
Fjord artisan
Joined: Apr 2006
Posts: 400 |
ok guys, thanks for helping me, and, thanks for the script hixxy.
-Kurdish_Assass1n
|
|
|
|
Joined: Apr 2006
Posts: 400
Fjord artisan
|
OP
Fjord artisan
Joined: Apr 2006
Posts: 400 |
ok, for the code, I wanted to be able to do this, instead of using /mix color-color, I just wanted to be able to do this, hope it's possible to do.
8-9 This is just an example of the script.
I know that haltdef doesn't go with input, and, I'm missing the ^, but, this was the only way that worked the best.I have changed the code and it's working but not all the way, here's what I mean: ------------------- Here's the code:
on *:INPUT:*: {
if ($gettok($1,1,45) isnum 0-15) || ($gettok($1,2,45) isnum 0-15) {
haltdef
var %colour1 = $base($gettok($1,1,45),10,10,2), %colour2 = $base($gettok($1,2,45),10,10,2), %ctoken = 1, %token, %result
while ($gettok($2-,%ctoken,32)) {
%token = $v1
if (2 \\ %ctoken) { %result = $+(%result $chr(3),%colour1,%token,$chr(3)) }
else { %result = $+(%result $chr(3),%colour2,%token,$chr(3)) }
inc %ctoken
}
say %result
}
}
Image: hopefully this is possible and easy to fix, I don't know what the problem is, but, hopefully someone else will, Thanks!
Last edited by Kurdish_Assass1n; 08/02/07 01:52 AM.
-Kurdish_Assass1n
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
var %colour1 = $base($gettok($remove($1,$chr(3)),1,45),10,10,2), %colour2 = $base($gettok($1,2,45),10,10,2), %ctoken = 1, %token, %result
You need to remove the Ctrl-K because it's treating the number as part of that code and ignoring it. You're basically looking at the $1 as being -9 instead of 8-9.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Oct 2005
Posts: 1,741
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,741 |
Try this:
on *:INPUT:*:{
if (($ctrlenter) || (!$regex($1,/^(\d\d?\-)+(\d\d?)$/))) return
var %m, %c = 0, %cc = $calc($0 - 1)
while (%c < %cc) {
inc %c
%m = %m $+(,$right($+(0,$gettok($1,$calc((%c - 1) % $numtok($1,45) + 1),45)),2)) $+ $gettok($2-,%c,32)
}
$iif($istok(channel.query,$window($active).type,46),msg $target,echo -a) %m
haltdef
}
Usage: 7-14-3 This is my test message $1 is the color string. It must begin with a ctrl-k code. You can have any number of colors, separated by dashes (-). ctrl+enter will abort the coloring. The text is /msg'd to channels/queries and echo'd to all other windows. -genius_at_work
|
|
|
|
Joined: Apr 2006
Posts: 400
Fjord artisan
|
OP
Fjord artisan
Joined: Apr 2006
Posts: 400 |
wow genius_at_work, thanks man, this worked great * Kurdish_Assass1n has to learn regex!
-Kurdish_Assass1n
|
|
|
|
|