Advertisement
Guest User

doorfinal2.lua

a guest
May 26th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. camera = peripheral.wrap("camera_0")
  2. mon = peripheral.wrap("right")
  3. mon.setTextScale(5)
  4. while true do
  5. mon.clear()
  6. mon.setCursorPos(1,1)
  7. mon.write(camera.distance())
  8. os.sleep(1)
  9. side = "back"
  10. function door(num)
  11. redstone.setBundledOutput(side, num)
  12. redstone.setBundledOutput("left", colors.yellow)
  13. sleep(.2)
  14. redstone.setBundledOutput(side, 0)
  15. sleep(1.5)
  16. end
  17. function open()
  18. repeat door(colors.orange)
  19. until camera.distance() == 5
  20. redstone.setBundledOutput("left", 0)
  21. end
  22. function close()
  23. repeat door(colors.white)
  24. until camera.distance() == 0
  25. redstone.setBundledOutput("left", 0)
  26. end
  27. if redstone.getInput("front") == true then
  28.     if camera.distance() == 5 then
  29.         close()
  30.         else open()
  31.     end
  32. end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement