Advertisement
Lion4ever

Turtle Compass with ladder/torch

Jul 22nd, 2015
1,011
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. local checkObs = true
  2.  
  3. if checkObs then
  4.   for i=1,4 do
  5.     if turtle.detect() then
  6.       turtle.dig()
  7.     end
  8.     turtle.turnRight()
  9.   end
  10.   turtle.digUp()
  11.   turtle.digDown()
  12. end
  13.  
  14. if type(turtle.getFuelLevel()) == "number" and turtle.getFuelLevel() < 2 then
  15.   print("Not enough Fuel")
  16.   return
  17. end
  18.  
  19. local torchesM = {"West","East","North","South","Invalid"}
  20.  
  21. local items = {["minecraft:ladder"]={"Invalid","South","North","East","West"},
  22.                ["minecraft:torch"]=torchesM,
  23.                ["minecraft:redstone_torch"]=torchesM}
  24.  
  25. for i=1,16 do
  26.   if turtle.getItemCount(i) > 0 and not items[turtle.getItemDetail(i).name] then
  27.     turtle.select(i)
  28.     if turtle.place() then
  29.       break
  30.     end
  31.   end
  32. end
  33.  
  34. repeat until turtle.up()
  35.  
  36. for i=1,16 do
  37.   if turtle.getItemCount(i) > 0 and items[turtle.getItemDetail(i).name] then
  38.     turtle.select(i)
  39.     turtle.placeDown()
  40.     break
  41.   end
  42. end
  43.  
  44. local d,b = turtle.inspectDown()
  45.  
  46. turtle.digDown()
  47. repeat until turtle.down()
  48. turtle.dig()
  49.  
  50. if not d then
  51.   print("That did not work")
  52.   return
  53. end
  54.  
  55. print(string.format("This turtle is facing %s",items[b.name][b.metadata]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement