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

Magic 8 Block!

Started by Cranium, 08 August 2012 - 11:46 PM
Cranium #1
Posted 09 August 2012 - 01:46 AM
Ask the Magic 8 Block ANYTHING, and get your answer! Careful though, you might not like seeing into the future…

Spoiler

local 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
edit: You may need to tweak the positioning of some of the ASCII, since it doesn't want to display properly here…
Pastebin
Edited on 14 August 2012 - 12:26 PM
cant_delete_account #2
Posted 14 August 2012 - 03:06 AM
Use local on the answer variable?
Cranium #3
Posted 14 August 2012 - 03:25 AM
Use local on the answer variable?
Didn't notice that. I'll fix it now!
Lettuce #4
Posted 14 August 2012 - 12:07 PM
I was kind of doubtful when I asked it "Can you see the future?" and it said "No," but it was just kidding.
It's predicted many things… oh yes, many, many things… It's not safe here. They're watching me. They're in the walls… they're in my shoes…
They don't know I'm on to them. They don't know the Magic 8 Block is telling me ALL their secrets… They're getting brave now. Testing me. An hour ago they sent a bee after me. They KNOW I'm afraid of bees… the Magic 8 Block said so…

ALSO: Fun program. Had to be a lot of work trying to get it all lined up right. We need more fun little programs like this. Great job. Oh come on, you knew someone was going to make a paranoia joke sooner or later.
BigSHinyToys #5
Posted 14 August 2012 - 12:26 PM
I was kind of doubtful when I asked it "Can you see the future?" and it said "No," but it was just kidding.
It's predicted many things… oh yes, many, many things… It's not safe here. They're watching me. They're in the walls… they're in my shoes…
They don't know I'm on to them. They don't know the Magic 8 Block is telling me ALL their secrets… They're getting brave now. Testing me. An hour ago they sent a bee after me. They KNOW I'm afraid of bees… the Magic 8 Block said so…

ALSO: Fun program. Had to be a lot of work trying to get it all lined up right. We need more fun little programs like this. Great job. Oh come on, you knew someone was going to make a paranoia joke sooner or later.
Tin hatters unite we march on the capital because this block foretold it. lol XD
is a cool little app
[EDIT]
fixed
Cranium #6
Posted 14 August 2012 - 02:25 PM
Tin hatters unite we march on the capital because this ball foretold it. lol XD
is a cool little app
….it's a block, not a ball.