This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
UrASmurf's profile picture

Magic 8ball.

Started by UrASmurf, 08 August 2012 - 07:35 PM
UrASmurf #1
Posted 08 August 2012 - 09: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 ;)/>/>
Cranium #2
Posted 08 August 2012 - 09: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 on 08 August 2012 - 09:52 PM
OmegaVest #3
Posted 08 August 2012 - 10:14 PM
Slight modification.


      print(answer[math.random(1, #answer)])  --Thus, you know longer NEED to know how many answers there are.
Cranium #4
Posted 08 August 2012 - 11:51 PM
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!
Cranium #5
Posted 09 August 2012 - 01: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!
UrASmurf #6
Posted 09 August 2012 - 06:45 AM
HOLY SHIZ DUDE. THANK YOU!

I love you all ;3
ChiknNuggets #7
Posted 09 August 2012 - 08: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("				    '----------------' ")
Pharap #8
Posted 09 August 2012 - 11:09 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("					'----------------' ")

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


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.
Cranium #9
Posted 09 August 2012 - 02: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.
BigSHinyToys #10
Posted 09 August 2012 - 02:31 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.
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.
Cranium #11
Posted 09 August 2012 - 02:36 PM
Pastebin Link
UrASmurf #12
Posted 09 August 2012 - 06: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.
Cranium #13
Posted 09 August 2012 - 07: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!
UrASmurf #14
Posted 09 August 2012 - 07:38 PM
Erm. I am playing on a server, which is why I needed help using codes to get it once HTTP is enabled ;)/>/>
BigSHinyToys #15
Posted 09 August 2012 - 08: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
UrASmurf #16
Posted 09 August 2012 - 09:39 PM
Tested it out and it is awesome. But how do I exit? D:
cant_delete_account #17
Posted 09 August 2012 - 09:43 PM
Tested it out and it is awesome. But how do I exit? D:
Hold CTRL+T.
Cranium #18
Posted 09 August 2012 - 09:47 PM
Next you add SPARKLES when shaking!!!!