Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function Mine_Stairs()
- -- Ask the Player how often to place a torch
- print("How often should the turtle place a torch? (e.g., every 4 stairs)")
- local torchFrequency = tonumber(io.read()) or 4
- local stepCount = 0
- while true do
- local fuelLevel = turtle.getFuelLevel()
- -- Fuel check
- if fuelLevel == "unlimited" then
- print("Fuel Level: Unlimited")
- elseif fuelLevel < 500 then
- print("Warning: Low Fuel! (" .. fuelLevel .. ")")
- else
- print("Fuel Level: " .. fuelLevel)
- end
- -- Refuel if fuel is low
- if fuelLevel < 500 then
- for i = 1, 15 do
- turtle.select(i)
- if turtle.refuel(0) then
- turtle.refuel()
- break
- end
- end
- end
- stepCount = stepCount + 1
- -- Dig the block in front of the turtle and move forward
- turtle.dig()
- turtle.forward()
- -- Dig blocks above and below the turtle
- turtle.digUp()
- turtle.digDown()
- -- Turn right every 2 steps
- if stepCount % 2 == 0 then
- turtle.turnRight()
- stepCount = stepCount - 2 -- Subtract 2 after turning to track the next steps correctly
- end
- -- Place a torch at the specified frequency
- if stepCount % torchFrequency == 0 then
- turtle.select(16)
- turtle.turnLeft()
- turtle.dig()
- turtle.place()
- turtle.turnRight()
- print("Torch placed at stair " .. stepCount)
- end
- -- Stop the loop if an obstacle is detected
- if not turtle.forward() then
- print("Obstacle detected. Stopping.")
- break
- end
- end
- end
- Mine_Stairs()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement