Advertisement
Mr_Chou

3x3x2 Staircase mine

Jan 5th, 2025 (edited)
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.85 KB | Gaming | 0 0
  1. local function Mine_Stairs()
  2.     -- Ask the Player how often to place a torch
  3.     print("How often should the turtle place a torch? (e.g., every 4 stairs)")
  4.     local torchFrequency = tonumber(io.read()) or 4
  5.  
  6.     local stepCount = 0
  7.  
  8.     while true do
  9.         local fuelLevel = turtle.getFuelLevel()
  10.  
  11.         -- Fuel check
  12.         if fuelLevel == "unlimited" then
  13.             print("Fuel Level: Unlimited")
  14.         elseif fuelLevel < 500 then
  15.             print("Warning: Low Fuel! (" .. fuelLevel .. ")")
  16.         else
  17.             print("Fuel Level: " .. fuelLevel)
  18.         end
  19.  
  20.         -- Refuel if fuel is low
  21.         if fuelLevel < 500 then
  22.             for i = 1, 15 do
  23.                 turtle.select(i)
  24.                 if turtle.refuel(0) then
  25.                     turtle.refuel()
  26.                     break
  27.                 end
  28.             end
  29.         end
  30.  
  31.         stepCount = stepCount + 1
  32.  
  33.         -- Dig the block in front of the turtle and move forward
  34.         turtle.dig()
  35.         turtle.forward()
  36.  
  37.         -- Dig blocks above and below the turtle
  38.         turtle.digUp()
  39.         turtle.digDown()
  40.  
  41.         -- Turn right every 2 steps
  42.         if stepCount % 2 == 0 then
  43.             turtle.turnRight()
  44.             stepCount = stepCount - 2  -- Subtract 2 after turning to track the next steps correctly
  45.         end
  46.  
  47.         -- Place a torch at the specified frequency
  48.         if stepCount % torchFrequency == 0 then
  49.             turtle.select(16)
  50.             turtle.turnLeft()
  51.             turtle.dig()
  52.             turtle.place()
  53.             turtle.turnRight()
  54.             print("Torch placed at stair " .. stepCount)
  55.         end
  56.  
  57.         -- Stop the loop if an obstacle is detected
  58.         if not turtle.forward() then
  59.             print("Obstacle detected. Stopping.")
  60.             break
  61.         end
  62.     end
  63. end
  64.  
  65. Mine_Stairs()
  66.  
Tags: minecraft
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement