Advertisement
robocyclone

wither farm pc.lua

Mar 26th, 2023
893
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. local monitor = peripheral.wrap("monitor_2")
  2.  
  3. if not monitor then
  4.     error("Monitor not found! Double check peripheral name.")
  5. end
  6.  
  7. term.clear()
  8. term.setCursorPos(1,1)
  9. term.write("Running!")
  10.  
  11. term.redirect(monitor)
  12. local switch = false
  13. local eng = {[true] = "ON", [false] = "OFF"}
  14. local timer = os.startTimer(0)
  15. local headsTimer = os.startTimer(300)
  16.  
  17. local function oneThenTwo()
  18.     rs.setOutput("bottom", true) --Build frame
  19.     os.sleep(1)
  20.     rs.setOutput("bottom", false)
  21.     os.sleep(.5)
  22.     rs.setOutput("right", true) --Build head
  23.     os.sleep(1)
  24.     rs.setOutput("right", false)
  25. end
  26.  
  27. local function clearHeads()
  28.     rs.setOutput("left", true)
  29.     os.sleep(3)
  30.     rs.setOutput("left", false)
  31. end
  32.  
  33. local function termDraw()
  34.     term.clear()
  35.     term.setCursorPos(1,1)
  36.     write("Wither Farm")
  37.     term.setCursorPos(4, 4)
  38.     write("\n STATUS: " .. eng[switch])
  39. end
  40.  
  41. function Main()
  42.     termDraw()
  43.     while true do
  44.         local e, p = os.pullEvent()
  45.         if e == "timer" and p == timer then
  46.             if switch then
  47.                 oneThenTwo()
  48.             end
  49.             timer = os.startTimer(2)
  50.         elseif e == "timer" and p == headsTimer then
  51.             if switch then
  52.                 clearHeads()
  53.             end
  54.             headsTimer = os.startTimer(300)
  55.         elseif e == "monitor_touch" then
  56.             switch = not switch
  57.             Main()
  58.         end
  59.     end
  60. end
  61. Main()
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement