Advertisement
Guest User

ArvidStripMine.lua

a guest
Feb 23rd, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.77 KB | None | 0 0
  1. --MINING A STRIPMINE
  2.  
  3. --Local variables
  4. local depth = 5
  5. local turnLeft = true
  6. local number_of_tunnel_pairs = 2
  7. local piller_size = 3
  8.  
  9. --GOING FOREWARD ONCE
  10. local function forewardOnce()
  11.     u()
  12.     while turtle.detect() do
  13.         turtle.dig()
  14.     end
  15.     turtle.forward()
  16.     if turtle.detectUp() then
  17.         turtle.digUp()
  18.     end
  19.     if turtle.detectDown() then
  20.         turtle.digDown()
  21.     end
  22. end
  23.  
  24. local function u()
  25.     print("u")
  26. end
  27.  
  28. -- GOING FOREWARD IN A LINE
  29. local function forewardLine(Length)
  30.     current_length = Length
  31.     while current_length > 0 do
  32.         forewardOnce()
  33.         current_length = current_length - 1
  34.     end
  35. end
  36.  
  37.  
  38. --TURN AT END OF THE LINE
  39. local function turnAtEndOfLine()
  40.     if turnLeft == true then
  41.         turtle.turnLeft()
  42.     else
  43.         turtle.turnRight()
  44.     end
  45.     forewardLine(piller_size + 1)
  46.     if turnLeft == true then
  47.         turtle.turnLeft()
  48.     else
  49.         turtle.turnRight()
  50.     end
  51. end
  52.  
  53.  
  54. --DO TUNNEL PAIR
  55. local function tunnelPair()
  56.     forewardLine(depth)
  57.     turnAtEndOfLine()
  58.     forewardLine(depth)
  59. end
  60.  
  61.  
  62. --FUNCTION FOR FUNCTION BELLOW !IGNORE!
  63. local function turnSync()
  64.     if turnLeft == true then
  65.         turtle.turnLeft()
  66.     else
  67.         turtle.turnRight()
  68.     end
  69. end
  70.  
  71.  
  72. --FUNCTION FOR FUNCTION BELOW !IGNORE!
  73. local function turnSyncReverse()
  74.     if turnLeft == true then
  75.         turtle.turnRight()
  76.     else
  77.         turtle.turnLeft()
  78.     end
  79. end
  80.  
  81.  
  82. --TURN AT FRONT OF LINE
  83. local function turnAtFrontOfLine()
  84.     turnSync()
  85.     forewardLine(piller_size)
  86.     turnSyncReverse()
  87.     forewardOnce()
  88.     turnSyncReverse()
  89.     forewardLine(2*piller_size + 1)
  90.     turnSyncReverse()
  91.     forewardOnce()
  92.    
  93.     --Take away ugly stuff
  94.     turnSyncReverse()
  95.     forewardLine(piller_size)
  96.    
  97.     N = piller_size
  98.     while N > 0 do
  99.         turtle.back()
  100.         N = N - 1
  101.     end
  102.    
  103.     turnSync()
  104.    
  105. end
  106.  
  107.  
  108. --UPPDATE FUEL
  109. local function uppdateFuel(rFL)
  110.     while turtle.getFuelLevel() < rFL do
  111.         turtle.select(1)
  112.         if turtle.getItemCount() <= 1 then
  113.             waitForRefueling() --MAKE FUNCTION
  114.         end
  115.         turtle.refuel(1)
  116.     end
  117. end
  118.  
  119.  
  120. --REFUEL WAITING
  121. local function waitForRefueling()
  122.     print("TURTLE NEEDS FUEL in slot 1")
  123.     while true do
  124.         sleep(1)
  125.         if turtle.getFuelLevel() > 1 then
  126.             break
  127.         end
  128.     end
  129. end
  130.  
  131.  
  132. --MAIN
  133. local function main()
  134.     current_tunnel_pair = 1
  135.     while current_tunnel_pair <= number_of_tunnel_pairs do
  136.         tunnelPair()
  137.         turnAtFrontOfLine()
  138.         current_tunnel_pair = current_tunnel_pair + 1
  139.     end
  140. end
  141.  
  142.  
  143. --GETTING INPUT FUNCTION
  144. local function askForInput()
  145.     print("NOT MADE YET")
  146. end
  147.  
  148.  
  149. --RUNNING PROGRAM
  150. askForInput()
  151. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement