S3mpx

stripMine

Dec 22nd, 2020 (edited)
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. -- Programm for stripmining --
  2.  
  3. -- how many blocks should the main tunnel have --
  4. print("How far should I stripmine?")
  5. -- I fucked up the code on that so /2 lol --
  6. local Xlength = io.read()
  7. local length = Xlength/2
  8. -- variable digging sizes, why not --
  9. print("How deep should I dig in the sides?")
  10. local depth = io.read()
  11.  
  12. -- digs a block and moves in that place --
  13. local function dig()
  14.     turtle.dig()
  15.     turtle.forward()
  16. end
  17.  
  18. -- uses dig(), but breaks block above, so players can walk --
  19. local function digMain()
  20. -- max = 3, cause we want only every 3rd block to be stripmined --
  21.     for i=1, 3 do
  22.         turtle.digUp()
  23.         dig()
  24.     end
  25. end
  26.  
  27. -- makes a hole to the left by turning and using dig() times the amount of depth --
  28. local function leftHole()
  29.     turtle.digUp()
  30.     turtle.up()
  31.     turtle.turnLeft()
  32.     for i=1, depth do
  33.         dig()
  34.     end
  35. end
  36.  
  37. -- only uses dig() for depth times, since leftHole() positioned properly allready
  38. local function rightHole()
  39.     for i=1, depth do
  40.         dig()
  41.     end
  42. end
  43.  
  44. -- turns the turtle around and gets him back to the center --
  45. local function goBack()
  46.     turtle.turnLeft()
  47.     turtle.turnLeft()
  48.     for i=1, depth do
  49.         turtle.forward()
  50.     end
  51. end    
  52.  
  53. -- repeated mining process times length --
  54. for i=1, length do
  55.     digMain()
  56.     leftHole()
  57.     goBack()
  58.     rightHole()
  59.     goBack()
  60.     turtle.turnRight()
  61.     turtle.down()
  62. end
Add Comment
Please, Sign In to add comment