Advertisement
Guest User

stripmine.lua

a guest
Apr 5th, 2020
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.82 KB | None | 0 0
  1. gTorchSlot=1
  2. gBridgeSlot=2
  3. gFuelSlot=3
  4.  
  5. gLineNumber=1
  6. gBrancheNumber=2
  7.  
  8. gLineGap=14
  9. gBranchGap=3
  10.  
  11. gPosLine=0
  12. gPosBranch=0
  13. gPosStrip=0
  14.  
  15. function move(moveLength,moveDirection)
  16.     -- moves
  17.     -- 0 forward
  18.     -- 1 back
  19.     -- 2 up
  20.     -- 3 down
  21.     for i=1,moveLength do
  22.         if moveDirection==0 then
  23.             while turtle.forward()==false do end
  24.         elseif moveDirection==1 then
  25.             while turtle.back()==false do end
  26.         elseif moveDirection==2 then
  27.             while turtle.up()==false do end
  28.         elseif moveDirection==3 then
  29.             while turtle.down()==false do end
  30.         end
  31.     end
  32. end
  33.  
  34. function turnAround()
  35.     -- turns the turtle 180°
  36.     turtle.turnLeft()
  37.     turtle.turnLeft()
  38. end
  39.  
  40. function moveTo(moveToLine,moveToBranch,moveToStrip)
  41.     -- moves turtle to defined position
  42.  
  43. function mineFwd(digLength,torchAtEnd)
  44.     -- mines 1×2 tunnel (start top block)
  45.     -- if torchAtEnd==true, places torch on last block
  46.     for iFwd=1,digLength do
  47.         while turtle.detect() do
  48.             turtle.dig()
  49.             os.sleep(0.5)
  50.         end
  51.         move(1,0)
  52.         turtle.digDown()
  53.         move(1,3)
  54.         if turtle.detectDown() == false then
  55.             turtle.select(bridgeSlot)
  56.             turtle.placeDown()
  57.         end
  58.         move(1,2)
  59.     end
  60.     if torchAtEnd then
  61.         turtle.select(torchSlot)
  62.         turtle.placeDown()
  63.     end
  64. end
  65.  
  66. function branch(branchNum,branchDist,branchLength)
  67.     -- creates branches
  68.     for iBranch=1,branchNum do
  69.         mineFwd(branchDist,true)
  70.         turtle.turnRight()
  71.         mineFwd(branchLength,false)
  72.         turnAround()
  73.         move(branchLength,0)
  74.         mineFwd(branchLength,false)
  75.         move(branchLength,1)
  76.         turtle.turnRight()
  77.     end
  78.     move(branchNum*branchDist,1)
  79. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement