Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Mining Turtle Program for Gravel/Andesite
- -- Version 1.1.1 for CC: Tweaked 1.21.1
- -- SemVer: MAJOR.MINOR.PATCH
- --[[ Changelog:
- v1.1.1 - Fixed fuel system to scan all slots for fuel
- v1.1.0 - Added proper SemVer version tracking and display
- v1.0.0 - Initial release with basic mining functionality
- ]]
- -- Configuration
- local VERSION = "1.1.1"
- local START_POS = vector.new(-279, 64, -182)
- local MAX_Y = 70
- local MIN_FUEL = 100
- local PREFERRED_FUEL_SLOT = 16 -- Preferred slot for fuel, but will search all slots
- -- Block types to mine
- local TARGET_BLOCKS = {
- ["minecraft:gravel"] = true,
- ["minecraft:andesite"] = true,
- ["minecraft:diorite"] = true,
- ["minecraft:granite"] = true
- }
- -- Turtle state
- local pos = vector.new(START_POS.x, START_POS.y, START_POS.z)
- local facing = "north" -- Initial facing direction
- local visited = {} -- Track visited positions to prevent infinite loops
- -- Direction vectors
- local directions = {
- north = vector.new(0, 0, -1),
- east = vector.new(1, 0, 0),
- south = vector.new(0, 0, 1),
- west = vector.new(-1, 0, 0)
- }
- -- Helper functions
- local function log(message)
- print(os.date("[%H:%M:%S] ") .. message)
- end
- local function printVersion()
- term.clear()
- term.setCursorPos(1,1)
- print("==== Mining Turtle Program ====")
- print("Version: " .. VERSION)
- print("CC: Tweaked 1.21.1")
- print("==============================")
- print()
- end
- local function findFuel()
- -- First try preferred slot
- turtle.select(PREFERRED_FUEL_SLOT)
- if turtle.refuel(0) then -- Test if item is fuel
- return PREFERRED_FUEL_SLOT
- end
- -- Search all slots for fuel
- for slot = 1, 16 do
- if slot ~= PREFERRED_FUEL_SLOT then -- Skip already checked preferred slot
- turtle.select(slot)
- if turtle.refuel(0) then
- return slot
- end
- end
- end
- return nil -- No fuel found
- end
- local function checkFuel()
- if turtle.getFuelLevel() >= MIN_FUEL then
- return true
- end
- log("Low fuel! Searching for fuel...")
- local fuelSlot = findFuel()
- if fuelSlot then
- turtle.select(fuelSlot)
- local before = turtle.getFuelLevel()
- if turtle.refuel(1) then
- local gained = turtle.getFuelLevel() - before
- log(("Refueled with slot %d (+%d fuel). Total: %d"):format(fuelSlot, gained, turtle.getFuelLevel()))
- return true
- end
- end
- log("No fuel found in any slot!")
- return false
- end
- -- ... [rest of the functions remain the same as in v1.1.0] ...
- -- Main program
- printVersion()
- log("Starting mining turtle at position " .. pos.x .. " " .. pos.y .. " " .. pos.z)
- log("Target blocks: gravel, andesite, diorite, granite")
- log("Max Y level: " .. MAX_Y)
- -- Initial fuel check
- if not checkFuel() then
- log("Initial fuel level too low and no fuel found!")
- log("Please add fuel (coal, lava buckets, etc.) to any slot")
- return
- end
- -- Start mining
- explore()
- log("Mining operation complete!")
- log("Final position: " .. pos.x .. " " .. pos.y .. " " .. pos.z)
- log("Remaining fuel: " .. turtle.getFuelLevel())
Add Comment
Please, Sign In to add comment