Advertisement
Inlife

piston-pusher.lua

Apr 16th, 2024 (edited)
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function iterate()
  2.     local timer = os.startTimer(5)
  3.     local event = os.pullEvent()
  4.  
  5.     if event ~= "redstone" and event ~= "timer" then
  6.         return
  7.     end
  8.    
  9.     if event == "redstone" then
  10.         if not redstone.getInput("bottom") and not redstone.getInput("left") then
  11.             return
  12.         end
  13.     end
  14.  
  15.     os.cancelTimer(timer)
  16.     print("[cr] caught event")
  17.     sleep(0.1)
  18.  
  19.     print("[cr] pushing piston")
  20.     redstone.setOutput("right", true)
  21.     sleep(0.1)
  22.  
  23.     print("[cr] retracting piston")
  24.     redstone.setOutput("right", false)
  25.     sleep(0.3)
  26. end
  27.  
  28. function main()
  29.     print("\n\n-------------------------------")
  30.     print("[cr] starting the program; v1.0")
  31.     print("-------------------------------\n\n");
  32.  
  33.     while true do
  34.         iterate()
  35.     end
  36. end
  37.  
  38. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement