Guest User

LandMark Placer

a guest
Jul 14th, 2013
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.40 KB | None | 0 0
  1. function checkFuel()
  2.         if(turtle.getFuelLevel() < 2) then
  3.                 turtle.select(16)
  4.                 if(turtle.refuel(1)==false) then
  5.                         print("Turtle needs more fuel in slot 16.")
  6.                         print("Press enter to continue.")
  7.                         io.read()
  8.                         checkFuel()
  9.                 end
  10.                 turtle.select(15)
  11.         end
  12. end
  13.  
  14.  function moveUp()
  15.         checkFuel()
  16.         while(turtle.up()==false)do turtle.digUp() end
  17. end
  18.  
  19. function moveDown()
  20.         checkFuel()
  21.         while(turtle.down()==false)do turtle.digDown() end
  22. end
  23.  
  24. function move()
  25.         checkFuel()
  26.         while(turtle.forward()==false)do turtle.dig() end
  27. end
  28.  
  29. function moveBack()
  30.         checkFuel()
  31.         while(turtle.back()==false)do end
  32. end
  33.  
  34. local args = { ... }
  35.  
  36. function main()
  37.     local quarryWidth
  38.  
  39.     if(#args == 1) then
  40.         quarryWidth = tonumber(args[1])
  41.         if(quarryWidth<2 or quarryWidth>64) then
  42.             print("Invalid Width")
  43.             return
  44.         end
  45.     else
  46.         print("Usage: "..shell.getRunningProgram().." <diameter>")
  47.         return
  48.     end
  49.    
  50.     for temp2=2,1,-1 do
  51.         for temp=quarryWidth-1,1,-1 do
  52.             move()
  53.         end
  54.         turtle.select(2)
  55.         turtle.digDown()
  56.         turtle.placeDown()
  57.         moveBack()
  58.         turtle.select(1)
  59.         turtle.place()
  60.                
  61.         for temp=quarryWidth-1,2,-1 do
  62.             moveBack()
  63.         end
  64.         turtle.turnRight()
  65.     end
  66.    
  67. end
  68.  
  69. main()
Advertisement
Add Comment
Please, Sign In to add comment