Advertisement
Guest User

startup2

a guest
Oct 26th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. modem = peripheral.wrap("right")
  2. modem.open(365)
  3. os.loadAPI("open")
  4. os.loadAPI("close")
  5.  
  6. while true do
  7. --  local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  8. local message = "open"
  9.   checkBarricade()
  10. end
  11.  
  12. function checkBarricade()  
  13.   turtle.dig()
  14.   turtle.forward()
  15.   turtle.forward()
  16.   turtle.turnRight()
  17.   turtle.forward()
  18.   if message == "open" then
  19.     if turtle.detect() then
  20.       open.openDoor()
  21.     elseif not turtle.detect() then
  22.       goHome()
  23.     end
  24.   elseif message == "close" then
  25.     if turtle.detect() then
  26.       goHome()
  27.     elseif not turtle.detect() then
  28.       close.closeDoor()
  29.     end
  30.   end            
  31. end
  32.  
  33. function goHome()
  34.   turtle.turnRight()
  35.   turtle.turnRight()
  36.   turtle.forward()
  37.   turtle.turnLeft()
  38.   turtle.forward()
  39.   turtle.forward()
  40.   turtle.turnRight()
  41.   turtle.turnRight()
  42.   turtle.place()
  43. end
  44.  
  45. while true do
  46.  
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement