Guest User

Branch

a guest
Jan 5th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. -- Variables
  2. turtle.select(1)
  3. local tArgs = { ... }
  4. local togo = tonumber(tArgs[1])
  5. togo = togo or 1
  6. print("Branching")
  7.  
  8. -- Functions
  9. function getFuel(amount)
  10.  if turtle.getFuelLevel() < 5 then
  11.   turtle.select(16)
  12.   turtle.refuel(amount)
  13.   turtle.select(1)
  14.  end
  15. end
  16.  
  17. function goBack()
  18.  turtle.turnRight()
  19.  turtle.turnRight()
  20. end
  21.  
  22. function mine()
  23.  if turtle.detectUp() then
  24.   turtle.digUp()
  25.  end
  26.  turtle.up()
  27.  if turtle.detectUp() == false then
  28.   turtle.select(2)
  29.   turtle.placeUp()
  30.   turtle.select(1)
  31.  end
  32.  turtle.turnRight()
  33.  if turtle.detect() == false then
  34.   turtle.select(2)
  35.   turtle.place()
  36.   turtle.select(1)
  37.  end
  38.  turtle.turnLeft()
  39.  turtle.turnLeft()
  40.  if turtle.detect() == false then
  41.   turtle.select(2)
  42.   turtle.place()
  43.   turtle.select(1)
  44.  end
  45.  turtle.turnRight()
  46.  turtle.down()
  47.  
  48.  
  49.  if turtle.detectDown() then
  50.   turtle.digDown()
  51.  end
  52.  turtle.down()
  53.  if turtle.detectDown() == false then
  54.   turtle.select(2)
  55.   turtle.placeDown()
  56.   turtle.select(1)
  57.  end
  58.  turtle.turnRight()
  59.  if turtle.detect() == false then
  60.   turtle.select(2)
  61.   turtle.place()
  62.   turtle.select(1)
  63.  end
  64.  turtle.turnLeft()
  65.  turtle.turnLeft()
  66.  if turtle.detect() == false then
  67.   turtle.select(2)
  68.   turtle.place()
  69.   turtle.select(1)
  70.  end
  71.  turtle.turnLeft()
  72.  turtle.up()
  73. end
  74.  
  75. -- Branching
  76. for i = 1, togo do
  77.  getFuel(1)
  78.  if turtle.detect() then
  79.   repeat
  80.    turtle.dig()
  81.    sleep(0.25)
  82.   until turtle.detect() == false
  83.   turtle.forward()
  84.   mine()
  85.  else
  86.   turtle.forward()
  87.   mine()
  88.  end
  89.  if togo >= 10 then
  90.   if (i % 10 == 0) then
  91.    turtle.placeDown()
  92.   end
  93.  end
  94. end
  95. -- Go Back
  96. goBack()
  97. for r = 1, togo do
  98.  getFuel(1)
  99.  turtle.forward()
  100. end
Advertisement
Add Comment
Please, Sign In to add comment