Advertisement
slay_mithos

Branch 0.8

Jan 13th, 2013
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.74 KB | None | 0 0
  1. local args = {...}
  2. -- Actual length = length*torchesInterval
  3. local length = 10
  4. local torchesInterval = 10
  5. local branches = 2
  6. local branchesinterval = 4
  7. local torchSlot = 1
  8. local chestSlot = 2
  9. local blockSlot = 3
  10. local fuelNeed = length * (torchesInterval+2)
  11.  
  12. local function forward()
  13.     while (not turtle.forward()) do
  14.         if (turtle.detect()) then
  15.             turtle.dig()
  16.         else
  17.             turtle.attack()
  18.         end
  19.     end
  20. end
  21.  
  22. local function down()
  23.     while (not turtle.down()) do
  24.         if (turtle.detectDown()) then
  25.             turtle.digDown()
  26.         else
  27.             turtle.attackDown()
  28.         end
  29.     end
  30. end
  31.  
  32. local function up()
  33.     while (not turtle.up()) do
  34.         if (turtle.detectUp()) then
  35.             turtle.digUp()
  36.         else
  37.             turtle.attackUp()
  38.         end
  39.     end
  40. end
  41.  
  42. local function dig()
  43.     turtle.digDown()
  44. end
  45.  
  46. local function alwaysFalse()
  47.     return false
  48. end
  49.  
  50. local function placeBlock(detect, place, slot)
  51.     if (not detect()) then
  52.         turtle.select(slot)
  53.         place()
  54.     end
  55. end
  56.  
  57. local function place(slot)
  58.     down()
  59.     dig()
  60.     placeBlock(alwaysFalse, turtle.placeDown, blockSlot)
  61.     up()
  62.     placeBlock(alwaysFalse, turtle.placeDown, slot)
  63. end
  64.  
  65. local function branchLoop()
  66.     for b=1, branches do
  67.         for i=1, length do
  68.             for j=1, torchesInterval do
  69.                 forward()
  70.                 placeBlock(turtle.detectUp, turtle.placeUp, blockSlot)
  71.                 dig()
  72.             end
  73.             place(torchSlot)
  74.         end
  75.         turtle.turnLeft()
  76.         for i=1, branchesinterval do
  77.             forward()
  78.             placeBlock(turtle.detectUp, turtle.placeUp, blockSlot)
  79.             dig()
  80.         end
  81.         place(torchSlot)
  82.        
  83.         turtle.turnRight()
  84.         forward()
  85.         place(chestSlot)
  86.         for k=16, blockSlot+1, -1 do
  87.             turtle.select(k)
  88.             turtle.dropDown()
  89.         end
  90.         turtle.turnLeft()
  91.         turtle.turnLeft()
  92.         forward()
  93.     end
  94. end
  95.  
  96. local function mainLoop()
  97.     branchLoop()
  98. end
  99.  
  100. mainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement