UNOBTANIUM

dt

Apr 7th, 2013
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. local message, position = "", ""
  2. local id, delay = 0 ,0.5
  3. turtle.select(1)
  4. rednet.open("right")
  5.  
  6. print("Current fuel level:" .. turtle.getFuelLevel())
  7. if turtle.getFuelLevel() < 10 then
  8.  print("This is too less!")
  9.  shutdown()
  10. end
  11.  
  12. if turtle.detectDown() and not turtle.detectUp() then
  13.  position = "ceiling"
  14. elseif turtle.detectUp() and not turtle.detectDown() then
  15.  position = "floor"
  16. end
  17.  
  18. if position == "" then
  19.  print("Turtle failed to find it's position.")
  20.  sleep(2)
  21.  shutdown()
  22. else
  23.  print("Current relativ position is the " .. position)
  24.  print("Waiting for rednet message!")
  25. end
  26.  
  27. while true do
  28.  id, message = rednet.receive()
  29.  sleep(delay)
  30.  if message == "open" and position == "ceiling" then
  31.   print("Opening!")
  32.   turtle.digDown()
  33.   turtle.up()
  34.   turtle.placeDown()
  35.  elseif message == "open" and position == "floor" then
  36.   print("Opening!")
  37.   turtle.digUp()
  38.   turtle.down()
  39.   turtle.placeUp()
  40.  elseif message == "close" and position == "ceiling" then
  41.   print("Closeing!")
  42.   turtle.digDown()
  43.   turtle.down()
  44.   turtle.placeDown()
  45.  elseif message == "close" and position == "floor" then
  46.   print("Closeing!")
  47.   turtle.digUp()
  48.   turtle.up()
  49.   turtle.placeUp()
  50.  end
  51. end
Advertisement
Add Comment
Please, Sign In to add comment