Advertisement
musictroopa

miner.lua

Oct 2nd, 2022 (edited)
896
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.86 KB | Gaming | 0 0
  1. local tArgs = { ... }
  2. local length = tonumber(tArgs[1])
  3. local width = tonumber(tArgs[2])
  4. local height = tonumber(tArgs[3])
  5. local turnRight = true
  6. local slot = 1
  7.  
  8. --Helper Functions
  9. function nextSlot()
  10.     if slot < 16 then
  11.         slot = slot + 1
  12.     else
  13.         slot = 1
  14.     end
  15.     turtle.select(slot)
  16. end
  17.  
  18. function place()
  19.     block = turtle.inspectDown()
  20.     if block then
  21.         if not turtle.compareDown() then
  22.             turtle.digDown()
  23.             turtle.placeDown()
  24.         end
  25.     end
  26. end
  27.  
  28.  
  29.  
  30. -- Main Function --
  31.  
  32. function main()
  33.    
  34.     if width == nil then
  35.         print("1. Place turtle (with pickaxe) facing direction of said mining (cube) area on left side and above the first layer you want to mine.")
  36.         print("2. Load turtle with enough fuel for mining.")
  37.         print("3. Type 'platform <length> <width> <height>'")
  38.         return 0
  39.     end
  40.    
  41.     turtle.select(slot)
  42.     turtle.refuel();
  43.  
  44.     turtle.dig()
  45.     turtle.forward()
  46.  
  47.     -- For Every 3 Levels of Height
  48.     for k = 0, height, 3 do
  49.         -- For Every block of width
  50.         for j = 1, width, 1 do
  51.  
  52.             -- For every block of length
  53.             for i = 1, length, 1 do
  54.                 if turtle.getItemCount(slot) == 0 then
  55.                     nextSlot()
  56.                 else
  57.                     turtle.refuel()
  58.                 end
  59.  
  60.                 turtle.digUp()
  61.                 turtle.digDown()
  62.  
  63.                 if i < length then
  64.                     turtle.dig()
  65.                     turtle.forward()
  66.                 end
  67.             end
  68.  
  69.             if j < width then
  70.  
  71.                 if turnRight == true then
  72.                     turtle.turnRight()
  73.                     turtle.dig()
  74.                     turtle.forward()
  75.                     turtle.turnRight()
  76.                     turnRight = false
  77.                 else
  78.                     turtle.turnLeft()
  79.                     turtle.dig()
  80.                     turtle.forward()
  81.                     turtle.turnLeft()
  82.                     turnRight = true
  83.                 end
  84.             end
  85.         end
  86.  
  87.         if k < height then
  88.             turtle.digUp()
  89.             turtle.up()
  90.             turtle.digUp()
  91.             turtle.up()
  92.             turtle.digUp()
  93.             turtle.up()
  94.             turtle.turnRight()
  95.             turtle.turnRight()
  96.  
  97.             -- due to orientation magic, we don't need to 'not' our turnRight variable
  98.         end
  99.     end
  100. end
  101.  
  102. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement