# Magic 8-ball

### By Elijah on Oct 31, 2009

This is just another magic 8-ball, say !8ball and then your question to be given an answer, by the way, it only answers yes or no questions :P

Use: !8ball QUESTION

Example:
<%JohnSmith> !8ball Will I win \$1 million dollars?
<@uBot> Original Question: Will I win \$1 million dollars? Answer:
<@uBot> Have you gone mad?! I think you have

Enjoy!

UPDATE: Fixed all the bugs :)

``````on *:TEXT:!8ball*:#: {
set %8ball \$rand(1,11)

msg \$chan Original question: \$2- Answer:

if (%8ball == 1) { msg \$chan No! }
if (%8ball == 2) { msg \$chan Yes! }
if (%8ball == 3) { msg \$chan Of course }
if (%8ball == 4) { msg \$chan Have you gone mad?! I think you have }
if (%8ball == 5) { msg \$chan How should I know? Its not like I'm magic }
if (%8ball == 6) { msg \$chan Heck no! }
if (%8ball == 7) { msg \$chan Maybe... yeah }
if (%8ball == 8) { msg \$chan Why should I tell you? }
if (%8ball == 9) { msg \$chan If I say yes will you be quiet? }
if (%8ball == 10) { msg \$chan Yes... that will be 30 dollars }
if (%8ball == 11) { msg \$chan How should I say this? Um... no }
}
``````

RJ12   -  Dec 19, 2009

Thanks Elijah it worked!

Can you post the time script and your other ones for Auto (If you dont mind sharing)

Jethro   -  Nov 07, 2009

You can also do it this way:

``````on *:TEXT:*:#: {
tokenize 32 \$strip(\$1-)
if (\$1 == !8ball) {
msg \$chan Original question: \$2- And the answer is:
var %x = No!|Yes!|Of course|Have you gone mad?! I think you have|\$&
How should I know? Its not like I'm magic|Heck no!|Maybe... yeah|Why should I tell you?|\$&
If I say yes will you be quiet?|Yes... that will be 30 dollars|How should I say this? Um... no
msg \$chan \$gettok(%x,\$rand(1,\$numtok(%x,124)),124)
}
}
``````
sunslayer   -  Nov 07, 2009

\$rand(1,8) returns a random number between 1 and 8, the 124) was the third param from \$gettok

3nigmat1c   -  Nov 07, 2009

\$rand(1,8),124)

What does that do?

Ghost-writer   -  Nov 07, 2009

\$gettok would make this 3 lines :>, example?

``````on *:TEXT:!ball*:#: {
msg \$chan The reply to your question: \$strip(\$2) \$+ , would have to be!
msg \$chan \$gettok(No|Yes|Maybe|Another time|When i die|in a million years|lick my nuts?|of course,\$rand(1,8),124)
}
``````
3nigmat1c   -  Nov 07, 2009

Jethro yours is cool... If there is not so many people on the channel. It gets a bit irritating when you like, in a heated discussion and your bot randomly gives frustrating input, but still awesome :) Nice 8ball Elijah

sunslayer   -  Nov 02, 2009

you could always throw in a \$gettok to shorten it

Elijah   -  Nov 02, 2009

Thanks Jehtro_, I'll consider all that

Jethro   -  Nov 01, 2009

This will make sure anything asked follows with the question mark at the end of a question:

``````on \$*:TEXT:/(?<=\x3F)/S:#: {
msg \$chan Original question: \$strip(\$2-) And the answer is:
var %8ball = \$rand(1,11)
if (%8ball == 1) { msg \$chan No! }
if (%8ball == 2) { msg \$chan Yes! }
if (%8ball == 3) { msg \$chan Of course }
if (%8ball == 4) { msg \$chan Have you gone mad?! I think you have }
if (%8ball == 5) { msg \$chan How should I know? Its not like I'm magic }
if (%8ball == 6) { msg \$chan Heck no! }
if (%8ball == 7) { msg \$chan Maybe... yeah }
if (%8ball == 8) { msg \$chan Why should I tell you? }
if (%8ball == 9) { msg \$chan If I say yes will you be quiet? }
if (%8ball == 10) { msg \$chan Yes... that will be 30 dollars }
if (%8ball == 11) { msg \$chan How should I say this? Um... no }
}
``````

Last but not least, you could have chosen the local variable instead of the global variable. This uses the same command that you've indicated.

Elijah   -  Oct 31, 2009

Yeah I decided to go over my whole script to make sure nothing woulf interfere and removed that line of code from it, it wasn't working with it anyway, kept unsetting it before giving a result for some reason

Elijah   -  Oct 31, 2009

I chose to unset it because I like to do that for my channel since well I have it full of scripts

Ghost-writer   -  Oct 31, 2009
``````on *:TEXT:!8ball*:#: {
set %8ball \$rand(1,12)
msg \$chan Original question: \$2- Answer:
if(%8ball == 1) { msg \$chan No! }
if(%8ball == 2) { msg \$chan Yes! }
if(%8ball == 3) { msg \$chan Of course }
if(%8ball == 4) { msg \$chan Have you gone mad?! I think you have }
if(%8ball == 5) { msg \$chan How should I know? Its not like I'm magic }
if(%8ball == 6) { msg \$chan Heck no! }
if(%8ball == 7) { msg \$chan Maybe... yeah }
if(%8ball == 1) { msg \$chan Why should I tell you? | .timer 1 2 msg \$chan BTW don't try and bribe me! }
if(%8ball == 8) { msg \$chan If I say yes will you be quiet? }
if(%8ball == 9) { msg \$chan Yes... that will be 30 dollars }
if(%8ball == 10) { msg \$chan How should I say this? Um... no }
unset %8ball
}
``````

Why are there so many 8balls on hawkee!!! argh! You should also use var %8ball so you dont need to unset it.
i guess you could try sockets but for purposes of this, you dont need the brackets. so like.

``````on *:TEXT:!8ball*:#: {
var %8ball \$rand(1,12)
msg \$chan Original question: \$2- Answer:
if %8ball == 1 msg \$chan No!
if %8ball == 2  msg \$chan Yes!
if %8ball == 3  msg \$chan Of course
if %8ball == 4 msg \$chan Have you gone mad?! I think you have
if %8ball == 5  msg \$chan How should I know? Its not like I'm magic
if %8ball == 6  msg \$chan Heck no!
if %8ball == 7 msg \$chan Maybe... yeah
if %8ball == 1 msg \$chan Why should I tell you? | .timer 1 2 msg \$chan BTW don't try and bribe me!
if %8ball == 8 msg \$chan If I say yes will you be quiet?
if %8ball == 9 msg \$chan Yes... that will be 30 dollars
if %8ball == 10 msg \$chan How should I say this? Um... no
}
``````

And theres your code improved and 100% working.

sunslayer   -  Oct 31, 2009

there are really too many of these :/

IF(%8BALL Unknown commandspace out ur /if's and their params

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.