Dojnaz

main

Oct 28th, 2020 (edited)
719
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (not fs.exists("config")) then
  2.   shell.run("pastebin get d41aYUsX config")
  3. end
  4. if (fs.exists("button")) then
  5.   fs.delete("button")
  6. end
  7. local isDebug = false
  8.  
  9. shell.run("pastebin get qc4QeDgu button")
  10. os.loadAPI("button")
  11. os.loadAPI("config")
  12.  
  13. local mon = peripheral.wrap(config.monitorId)
  14.  
  15. function reboot()
  16.   os.reboot()
  17. end
  18.  
  19. function debug()
  20.   if (isDebug) then
  21.     isDebug = false
  22.   else
  23.     isDebug = true
  24.   end
  25.   redstone.setOutput(config.debugSide, isDebug)
  26. end
  27.  
  28. function givePrice(count)
  29.   for i = count-1,1,-1 do
  30.     redstone.setOutput(config.priceSide, true)
  31.     sleep(0.1)
  32.     redstone.setOutput(config.priceSide, false)
  33.     sleep(0.1)
  34.   end
  35.   if (count > 0) then
  36.     redstone.setOutput(config.priceSide, true)
  37.     sleep(0.8)
  38.     redstone.setOutput(config.priceSide, false)
  39.   end
  40.   sleep(0.1)
  41. end
  42.  
  43. function kill()
  44.   mon.setTextScale(2)
  45.   mon.clear()
  46.   mon.setCursorPos(8,10)
  47.   mon.write("The program has exited!")
  48.   error("Exited on user input")
  49. end
  50.  
  51. button.setTable("give price", function () givePrice(8) end, 44, 53, 26, 26)
  52. button.setTable("exit", kill, 55, 58, 26, 26)
  53. button.setTable("debug", debug, 60, 64, 26, 26)
  54. button.setTable("reboot", reboot, 66, 71, 26, 26)
  55. button.screen()
  56.  
  57. function getClick()
  58.   event,side,x,y = os.pullEvent("monitor_touch")
  59.   button.checkxy(x,y)
  60. end
  61.  
  62. while (true) do
  63.   getClick()
  64. end
  65.  
RAW Paste Data