Advertisement
melzneni

sys2_service_doors_tDoor3x3

Feb 20th, 2020
923
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. --sys2_service_doors_tDoor3x3
  2. args = { ... }
  3. local rootId = tonumber(args[1])
  4. local bootUnitId = tonumber(args[2])
  5.  
  6. os.loadAPI("sys/syslib")
  7.  
  8. function imp(side)
  9. redstone.setOutput(side, false)
  10. redstone.setOutput(side, true)
  11. sleep(0.1)
  12. redstone.setOutput(side, false)
  13. sleep(0.15)
  14. end
  15.  
  16. function chain(sides)
  17. for i, side in ipairs(sides) do
  18. imp(side)
  19. end
  20. end
  21.  
  22. function open()
  23. chain({"left", "bottom", "top", "right", "top", "left" })
  24. end
  25.  
  26. function close()
  27. chain({ "left", "bottom", "left" })
  28. end
  29.  
  30. while true do
  31. local id, msg = syslib.receiveRednet()
  32. local tag, pts = syslib.getMsgData(msg)
  33. if tag == "@door" then
  34. if pts[1] == "open" then
  35. open()
  36. elseif pts[1] == "close" then
  37. close()
  38. else print("unknown command: " .. pts[1])
  39. end
  40. end
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement