Jump to content




Magic 8ball.


  • You cannot reply to this topic
17 replies to this topic

#1 UrASmurf

  • New Members
  • 13 posts

Posted 08 August 2012 - 08:35 PM

I know, I know, two posts within like an hour, but I really want someone to make this for me.

Basically it is a magic 8ball, where you ask a question, and it gives you a random answer like "Signs point to yes" or something.

I understand for the random answer it could be something like phrases{"blah","anotherone",} and math.random etc. from another guy, but if someone could put it together all nice for me that would be awesome ;)/>

#2 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 08 August 2012 - 08:54 PM

Not tested, but I think this should work:
answer = {
"Maybe Later",
"Try Again",
"No",
"Yes"
--you can add more if you want.
}
while true do
term.clear()
term.setCursorPos(1,1)
print("						  Magic 8-Ball")
print("Please ask a question, and press enter!")
term.setCursorPos(1,9)
write("Question: ")
event, p1 = os.pullEvent("key")
  if p1 == "28" then
	print(answer[math.random(1,#answer)]) --Apparently you just need to fill out the answers now...
  end
end

Edited by craniumkid22, 08 August 2012 - 10:52 PM.


#3 OmegaVest

  • Members
  • 436 posts

Posted 08 August 2012 - 09:14 PM

Slight modification.

      print(answer[math.random(1, #answer)])  --Thus, you know longer NEED to know how many answers there are.


#4 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 08 August 2012 - 10:51 PM

View PostOmegaVest, on 08 August 2012 - 09:14 PM, said:

Slight modification.

	  print(answer[math.random(1, #answer)])  --Thus, you know longer NEED to know how many answers there are.
Did not know that.... Good to know!

#5 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 09 August 2012 - 12:44 AM

I have just made this more awesome because you guys gave me inspiration. New code here:
answer = {
"It is Certain ",
" Decidedly So ",
"	  No	  ",
"	  Yes	 ",
"   No doubt   ",
"	 Never    ",
"    Unknown   ",
"  Ask again   ",
"   Doubtful   ",
" Most Likely  ",
"Cannot predict",
" Probably not ",
" Stars say no ",
"   For sure   ",
"   Why not?   ",
"	 Why?	 "
}
function logo()
term.clear()
term.setCursorPos(1,1)
print("  _ _ _				  __	  __    _		  ")
print(" ' ) ) )			    (  )    /  )  //	   /  ")
print("  / / / __.  _,  o _.   ./'    /--<  // __ _. /_  ")
print(" / ' (_(_/|_(_)_<_(__  (__)   /___/_</_(_)(__/ <_ ")
print("			 /|								   ")
print("		    |/								    ")
end
function start()
logo()
term.setCursorPos(1,7)
print("			    .----------------.			    ")
print("Ask me ANY	 | .--------------. |   Whether you ")
print("question, and  | |	 ____	 | |    like it... ")
print("press ENTER    | |   .' __ '.   | |			   ")
print("to receive	 | |   | (__) |   | |			   ")
print("your answer... | |   .'____'.   | |	 OR NOT... ")
print("			   | |  | (____) |  | |			   ")
print("			   | |  '.______.'  | |			   ")
print("			   | |			  | |			   ")
print("			   | '--------------' |			   ")
print("			    '----------------'			    ")
end
function shake()
term.clear()
logo()
term.setCursorPos(1,7)
print("				 .----------------. ")
print("			    | .--------------. |")
print("			    | |			  | |")
print("			    | |			  | |")
print("			    | |			  | |")
print("			    | |			  | |")
print("			    | |			  | |")
print("			    | |			  | |")
print("			    | |			  | |")
print("			    | '--------------' |")
print("				 '----------------' ")
sleep(.2)
term.clear()
logo()
term.setCursorPos(1,7)
print("			   .----------------. ")
print("			  | .--------------. |")
print("			  | |			  | |")
print("			  | |			  | |")
print("			  | |			  | |")
print("			  | |			  | |")
print("			  | |			  | |")
print("			  | |			  | |")
print("			  | |			  | |")
print("			  | '--------------' |")
print("			   '----------------' ")
sleep(.2)
term.clear()
logo()
term.setCursorPos(1,7)
print("			    .----------------. ")
print("			   | .--------------. |")
print("			   | |			  | |")
print("			   | |			  | |")
print("			   | |			  | |")
print("			   | |			  | |")
print("			   | |			  | |")
print("			   | |			  | |")
print("			   | |			  | |")
print("			   | '--------------' |")
print("			    '----------------' ")
sleep(.2)
term.clear()
logo()
term.setCursorPos(1,7)
print("				 .----------------. ")
print("			    | .--------------. |")
print("			    | |			  | |")
print("			    | |			  | |")
print("			    | |			  | |")
print("			    | |			  | |")
print("			    | |			  | |")
print("			    | |			  | |")
print("			    | |			  | |")
print("			    | '--------------' |")
print("				 '----------------' ")
sleep(.2)
term.clear()
logo()
term.setCursorPos(1,7)
print("			   .----------------. ")
print("			  | .--------------. |")
print("			  | |			  | |")
print("			  | |			  | |")
print("			  | |			  | |")
print("			  | |			  | |")
print("			  | |			  | |")
print("			  | |			  | |")
print("			  | |			  | |")
print("			  | '--------------' |")
print("			   '----------------' ")
sleep(.2)
term.clear()
logo()
term.setCursorPos(1,7)
print("			    .----------------. ")
print("			   | .--------------. |")
print("			   | |			  | |")
print("			   | |			  | |")
print("			   | |			  | |")
print("			   | |			  | |")
print("			   | |			  | |")
print("			   | |			  | |")
print("			   | |			  | |")
print("			   | '--------------' |")
print("			    '----------------' ")
sleep(1.5)
ans()
end
function ans()
term.clear()
logo()
term.setCursorPos(1,7)
print("			    .----------------. ")
print("			   | .--------------. |")
print("			   | |			  | |")
print("			   | |			  | |")
print("			   | |			  | |")
print("			   | |"..answer[math.random(1,#answer)].."| |") -- 14 lines missing
print("			   | |			  | |")
print("			   | |			  | |")
print("			   | |			  | |")
print("			   | '--------------' |")
print("			    '----------------' ")
end

start()
while true do
  local event, p1 = os.pullEvent("key")
  if p1 == 28 then
    shake()
sleep(2)
start()
  end
end
YOU WILL LOVE IT!

#6 UrASmurf

  • New Members
  • 13 posts

Posted 09 August 2012 - 05:45 AM

HOLY SHIZ DUDE. THANK YOU!

I love you all ;3

#7 ChiknNuggets

  • Members
  • 130 posts

Posted 09 August 2012 - 07:03 AM

you could make that a whole lot smaller if u made a function for the
term.setCursorPos(1,7)
print("				    .----------------. ")
print("				   | .--------------. |")
print("				   | |					 | |")
print("				   | |					 | |")
print("				   | |					 | |")
print("				   | |					 | |")
print("				   | |					 | |")
print("				   | |					 | |")
print("				   | |					 | |")
print("				   | '--------------' |")
print("				    '----------------' ")


#8 Pharap

  • Members
  • 816 posts
  • LocationEngland

Posted 09 August 2012 - 10:09 AM

View PostChiknNuggets, on 09 August 2012 - 07:03 AM, said:

you could make that a whole lot smaller if u made a function for the
term.setCursorPos(1,7)
print("					.----------------. ")
print("				   | .--------------. |")
print("				   | |					 | |")
print("				   | |					 | |")
print("				   | |					 | |")
print("				   | |					 | |")
print("				   | |					 | |")
print("				   | |					 | |")
print("				   | |					 | |")
print("				   | '--------------' |")
print("					'----------------' ")

No he couldn't, you probably haven't noticed but each of the slots is designed to move.


View Postcraniumkid22, on 09 August 2012 - 12:44 AM, said:

I have just made this more awesome because you guys gave me inspiration. New code here:
YOU WILL LOVE IT!

It's quite good, but the screen needs a bit of alignment. Do you want a bit of help with calculating it so it aligns properly? (on the computer and the monitor)
I've actually been thinking about writing a graphics api for making ascii graphics easier, so it will help me test some of my theories.

#9 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 09 August 2012 - 01:17 PM

Well it worked just fine when I created it in notepad++... Guess it didn't translate too well. I'll post a pastebin link soon.

#10 BigSHinyToys

  • Members
  • 1,001 posts

Posted 09 August 2012 - 01:31 PM

View Postcraniumkid22, on 09 August 2012 - 01:17 PM, said:

Well it worked just fine when I created it in notepad++... Guess it didn't translate too well. I'll post a pastebin link soon.
The forums here really mess with code Badly where spacing and indents are concerned. I normally provide a Copy on the forums and pastbin to make shore.

#11 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 09 August 2012 - 01:36 PM

Pastebin Link

#12 UrASmurf

  • New Members
  • 13 posts

Posted 09 August 2012 - 05:53 PM

Could someone give me a step by step on putting this on my computer? Server has that HTTP thing enabled, just don't know how to make it copy it onto computer as a program.

#13 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 09 August 2012 - 06:14 PM

I don't know about the HTTP API, but you can go to pastebin, copy the code, and then paste it into a "blank" program you created in CC. Create the "blank" program by typing edit "name here", pressing CTRL, and then save, CTRL, and exit. Go to your minecraft folder, and find the folder for that computer you're at, and open up that new program with notepad. paste the code, and you're done!

#14 UrASmurf

  • New Members
  • 13 posts

Posted 09 August 2012 - 06:38 PM

Erm. I am playing on a server, which is why I needed help using codes to get it once HTTP is enabled ;)/>

#15 BigSHinyToys

  • Members
  • 1,001 posts

Posted 09 August 2012 - 07:48 PM

Put this into your console Not in a program you can use Ctrl+V to past it in.
pastebin get RcM4ZPum 8ball
after that run 8ball
simple ha

#16 UrASmurf

  • New Members
  • 13 posts

Posted 09 August 2012 - 08:39 PM

Tested it out and it is awesome. But how do I exit? D:

#17 cant_delete_account

  • Members
  • 484 posts

Posted 09 August 2012 - 08:43 PM

View PostUrASmurf, on 09 August 2012 - 08:39 PM, said:

Tested it out and it is awesome. But how do I exit? D:
Hold CTRL+T.

#18 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 09 August 2012 - 08:47 PM

Next you add SPARKLES when shaking!!!!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users