lpenap

Computercraft Turtle Program to place Landmarks

Aug 15th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. -- Computercraft turtle program to place landmarks for a BC quarry
  2. -- Author: lpenap
  3. -- It will asume fuel is in slot 1 and landmarks in slot 2
  4. -- This is just a test, it has not reached minimum quality.
  5. -- It may not work as expected...
  6.  
  7. local SIDE=60
  8.  
  9. local function doRefuel(moves)
  10.     while (turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < moves) do
  11.       turtle.select(1)
  12.       turtle.refuel(1)
  13.     end
  14. end
  15. local function moveForward()
  16.   while (not turtle.forward()) do
  17.     if (turtle.detect()) then
  18.       turtle.dig()
  19.     else
  20.       turtle.attack()
  21.       os.sleep(1)
  22.     end
  23.   end
  24. end
  25. local function placeNextLandmark(placeMark)
  26.   doRefuel(SIDE+2)
  27.   for i=1,SIDE do
  28.     moveForward()
  29.   end
  30.   turtle.select(2)
  31.   if (placeMark) then
  32.     if (turtle.detect()) then
  33.       turtle.dig()
  34.     end    
  35.     turtle.place()
  36.   end
  37.   turtle.turnLeft()
  38. end
  39. local function placeLandmarks()
  40.   doRefuel(SIDE+2)
  41.   moveForward()
  42.   turtle.turnLeft()
  43.   turtle.turnLeft()
  44.   turtle.select(2)
  45.   turtle.place()
  46.   turtle.turnLeft()
  47.   turtle.turnLeft()
  48.   placeNextLandmark(true)
  49.   placeNextLandmark(false)
  50.   placeNextLandmark(true)
  51.   placeNextLandmark(false)
  52. end
  53.  
  54. placeLandmarks()
Advertisement
Add Comment
Please, Sign In to add comment