This is an 8-ball script with the same responses as the original 8-ball. It also records all questions and answers and repeats them at random if there are more than recordings. This script also includes spam protection (1 question every 5 seconds).
on *:TEXT:!8ball*:#:{
if ($right($1-,1) == ? && $numtok($1-,32) > 2) {
$iif(%8ball. [ $+ [ $address($nick,2) ] ],halt,inc -u5 %8ball. [ $+ [ $address($nick,2) ] ])
var %8ball = As I see it, yes_It is certain_It is decidedly so_Most likely_Outlook good_Signs point $&
to yes_Without a doubt_Yes_Yes - definitely_You may rely on it_Reply hazy, try again_Ask again later $&
_Better not tell you now_Cannot predict now_Concentrate and ask again_Don't count on it_My reply is no $&
_My sources say no_Outlook not so good_Very doubtful, %rand = $rand(1,3)
if (%rand == 1) { var %result = $gettok(%8ball,$rand(1,10),95) }
if (%rand == 2) { var %result = $gettok(%8ball,$rand(11,15),95) }
if (%rand == 3) { var %result = $gettok(%8ball,$rand(16,20),95) }
msg $chan %result
write scripts\8ball.txt < $+ $nick $+ > $1- A: %result $+ 15( $+ $server $asctime(mmm dd $+ $chr(44) yyyy hh:nn:ss tt) $+ )
if ($lines(scripts\8ball.txt) > 10 && $rand(1,3) == 1) { msg $chan Previous 8-Balls: $read(scripts\8ball.txt) }
}
else { msg $chan $nick $+ , your question either did not end in a question mark or was too short. }
}
I can see that, but in the script, he's separating each of the tokens through _ [$chr(95)], so "$&" that potentially separates the whole list into "yes/maybe/no" has no meaning towards the script.
Even if you take a third of the whole set, and then get a random value from the third, it's the same thing as getting one item from the whole list. And yes, I have just realized that the number of values are different for each section.
var %8ball = As I see it, yes_It is certain_It is decidedly so_Most likely_Outlook good_Signs point $&
to yes_Without a doubt_Yes_Yes - definitely_You may rely on it_Reply hazy, try again_Ask again later $&
_Better not tell you now_Cannot predict now_Concentrate and ask again_Don't count on it_My reply is no $&
_My sources say no_Outlook not so good_Very doubtful, %rand = $rand(1,3)
if (%rand == 1) { var %result = $gettok(%8ball,$rand(1,10),95) }
if (%rand == 2) { var %result = $gettok(%8ball,$rand(11,15),95) }
if (%rand == 3) { var %result = $gettok(%8ball,$rand(16,20),95) }
Even though the tokens are separated through "yes, maybe, and no" sections, if you are going to just take one item from the entire list, then there's no need to create another, separate random sequence that separates each of them. :\
I can understand that you're trying to change chances with 10 good (50%), 5 neutral (25%), 5 bad (25%).
But I think you're better off with:
var %8ball = As I see it, yes_It is certain_It is decidedly so_Most likely_Outlook good_Signs point $&
to yes_Without a doubt_Yes_Yes - definitely_You may rely on it_Reply hazy, try again_Ask again later $&
_Better not tell you now_Cannot predict now_Concentrate and ask again_Don't count on it_My reply is no $&
_My sources say no_Outlook not so good_Very doubtful
msg $chan $gettok(%8ball,$r(1,$numtok(%8ball,95)),95)
, where $numtok(%8ball,95) can be substituted with 20, in this case.