Advertisement
Guest User

simple_station_normal.lua

a guest
Apr 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 0
  1. local redstone = component.list("redstone")()
  2. local frontInput = 3
  3. local backOutput = 2
  4. local redstoneThreshold = 1
  5. local redstoneOutput = 4
  6. local redstoneIdle = 0
  7. function os.sleep(timeout)
  8.   local deadline = computer.uptime() + (timeout or 0)
  9.   repeat
  10.     computer.pullSignal(deadline - computer.uptime())
  11.   until computer.uptime() >= deadline
  12. end
  13.  
  14. assert(redstone, "Missing redstone card or block!")
  15. component.invoke(redstone, "setOutput", backOutput, redstoneIdle)
  16.  
  17. computer.beep(500,0.25)
  18. computer.beep(750,0.25)
  19. computer.beep(1000,0.25)
  20.  
  21. while true do
  22.   local name, _, side, _, value = computer.pullSignal()
  23.   if name == "redstone_changed" then
  24.     if side == frontInput then
  25.       if value >= redstoneThreshold then
  26.   computer.beep(400,0.25)
  27.   os.sleep(5)
  28.         component.invoke(redstone, "setOutput", backOutput, redstoneOutput)
  29.         computer.beep(1000, 0.1)
  30.         computer.beep(1000, 0.1)
  31.         computer.beep(1000, 0.1)
  32.       else
  33.   os.sleep(10)
  34.         component.invoke(redstone, "setOutput", backOutput, redstoneIdle)
  35.       end
  36.     end
  37.   end
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement