-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Name: DanielKermanStripMining (DKSM) -- -- Author: Daniel_Kerman -- -- Version: 1.0.1 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Initializing -- local rowsMined = {0} local totalRows = {0} local hallLength = {0} local fuelNeeded = {0} local fuelLevel = turtle.getFuelLevel() local fuelLimit = turtle.getFuelLimit() local startConfirmed = "No" local slot = turtle.getSelectedSlot() local itemSpace = turtle.getItemSpace() local torchCounter = 0 -- Declaring Functions -- function forward() -- Help from the user Foogles (http://www.computercraft.info/forums2/index.php?/user/46239-foogles/) -- THANK YOU FOR THIS BUG SOLUTION! local x = turtle.forward() if (x == false) then return forward() end end local function clear(column,row) term.clear() if column == nil and row == nil then column = 1 row = 1 elseif row == nil then row = 1 elseif column == nil then column = 1 end term.setCursorPos(column,row) end local function checkNumber(varToCheck) assert(type(varToCheck) == "number", "Program expected number. Got string or something else instead.") end local function fallingBlock() local success, data = turtle.inspect() local fBlocks = { sand="minecraft:sand", gravel="minecraft:gravel", anvil="minecraft:anvil", dragon_egg="minecraft:dragon_egg" } if data.name==fBlocks.sand or data.name==fBlocks.gravel or data.name==fBlocks.anvil or data.name==fBlocks.dragon_egg then return true else return false end end local function dig(length,back) for i=1, length do torchCounter=torchCounter+1 while fallingBlock() == true do turtle.dig() sleep(1) end turtle.dig() forward() turtle.digDown() if torchCounter >= 8 then turtle.select(16) if turtle.getItemSpace() < 64 then local data = turtle.getItemDetail() if data.name == "minecraft:torch" then turtle.placeDown() end end torchCounter = 0 turtle.select(1) end end if back == true then turtle.turnLeft() turtle.turnLeft() for i=2, length do forward() end forward() turtle.turnLeft() turtle.turnLeft() end end -- Welcome + User input -- clear(1,1) print("Welcome to the Strip Mining Program.") sleep(1) print("Please enter a Hall/Strip Length (x = x block/s): ") hallLength[1] = io.read() hallLength[1] = tonumber(hallLength[1]) checkNumber(hallLength[1]) print("Please enter a number of rows:") totalRows[1] = io.read() totalRows[1] = tonumber(totalRows[1]) checkNumber(totalRows[1]) print("Calculating if turtle has enough fuel...") fuelNeeded[1] = (hallLength[1]*3*totalRows[1])+(12*totalRows[1]) sleep(1.0) assert(fuelNeeded[1]