Advertisement
TomatoSoup

Untitled

Apr 12th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. local redin = "right"
  3. local redout = "bottom"
  4. local printerside = "left"
  5. math.randomseed(os.time())
  6.  
  7. local printer = peripheral.wrap(printerside) -- Wrap the printer
  8.  
  9. local stopme = true
  10.  
  11. local result, n1, n2, n3, hash, ready
  12.  
  13. while (true) do
  14. while (redstone.getInput(redin) and stopme) do
  15. stopme = false
  16. ready = printer.newPage()
  17. n1 = math.random(20)
  18. n2 = math.random(20)
  19. n3 = math.random(20)
  20. hash = (n1*n2*n3*541)%(n1+n2+n3+29) --10th and 100th primes
  21. result = n1 .. " " .. n2 .. " " .. n3 .. "\nHash Code: " .. hash
  22. write("Your lotto numbers are!\n" .. result .. "\n")
  23. if ready then
  24. printer.write(result)
  25. printer.setPageTitle("Lotto Ticket")
  26. printer.endPage()
  27. redstone.setOutput(redout, true)
  28. sleep(2)
  29. redstone.setOutput(redout, false)
  30. else
  31. error("Could not create a page. Is there any paper and ink in the printer?\n")
  32. end
  33. end
  34. if not redstone.getInput(redin) then
  35. shell.run("clear")
  36. write("Press enter for your ticket!\n\n")
  37. result = read()
  38. stopme = true
  39. end
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement