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

Dice Program

Started by jtdavis99, 04 March 2012 - 02:41 AM
jtdavis99 #1
Posted 04 March 2012 - 03:41 AM
A simple little program for all your dice-y needs :unsure:/>/>

 function os.pullEvent()
local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
if event == "terminate" then
os.reboot()
end
return event, p1, p2, p3, p4, p5
end

term.clear()
term.setCursorPos(1,1)
print("1: 6 sided die.")
print("2: 12 sided die.")
print("3: 20 sided die.")
print("")
input = read()
  sleep(1)
  term.clear()
  term.setCursorPos(1,1)
if input == "" then
print("Nothing isn't a number.")
sleep(1)
os.reboot()

  elseif input == "1" then
  print(math.random(1, 6))
  sleep(3)
  term.clear()
  term.setCursorPos(1,1)
  shell.run("shell")
 
  elseif input == "2" then
  print(math.random(1, 12))
  sleep(3)
  term.clear()
  term.setCursorPos(1,1)
  shell.run("shell")
 
  elseif input == "3" then
  print(math.random(1, 20))
  sleep(3)
  term.clear()
  term.setCursorPos(1,1)
  shell.run("shell")
 
  end
FuzzyPurp #2
Posted 04 March 2012 - 05:14 AM
I'm making cee-lo. Also - why the excessive shell.run("shell")'s?
Casper7526 #3
Posted 04 March 2012 - 06:12 AM
just type "return" instead of the shell.runs and it will do exactly what you want :unsure:/>
Edited on 01 May 2016 - 12:04 AM