Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --File: /digtunnel
- local moves = dofile("/cattech/moves.lua")
- local lists = dofile("/cattech/lists.lua")
- dofile("/cattech/common.lua")
- dofile("/cattech/file.lua")
- dofile("/cattech/comms.lua")
- local torchCounter = 7;
- local redstoneTorchCounter = 1;
- function checkTorch()
- torchCounter = torchCounter +1
- if (torchCounter > 7) then
- log("info","placing Torch!")
- moves.placeLight(2)
- torchCounter = 0
- end
- end
- function checkRedstoneTorch()
- redstoneTorchCounter = redstoneTorchCounter +1
- if (redstoneTorchCounter > 4) then
- log("info","placing Redstone Torch!")
- moves.up()
- moves.turnLeft()
- moves.forward()
- local placeItem = selectTurtleItemByList(lists.redstoneMarker)
- if placeItem ~= nil then
- turtle.placeDown(placeItem)
- end
- moves.turnRight()
- moves.turnRight()
- moves.forward()
- moves.forward()
- local placeItem = selectTurtleItemByList(lists.redstoneMarker)
- if placeItem ~= nil then
- turtle.placeDown(placeItem)
- end
- moves.turnLeft()
- moves.turnLeft()
- moves.forward()
- moves.turnRight()
- moves.down()
- redstoneTorchCounter = 0
- end
- end
- config = loadConfigAndDefaults()
- if #arg >= 1 then
- config["maxSteps"] = tonumber(arg[1])
- if #arg >= 2 then
- config["pathDirection"] = arg[2]
- end
- else
- local continue = getContinue("digtunnel")
- if continue ~= nil then
- log("info","Continuing remaining: ",continue)
- config["maxSteps"] = continue
- end
- end
- displayHash(config)
- local haveRednet = initializeRednetModem()
- log("info","Going " .. config["pathDirection"] .. " " .. config["maxSteps"] .. " blocks")
- if (config["pathDirection"] == "mineshaft") then
- config["pathDirection"] = "level"
- end
- local spaces = 0
- while spaces < config["maxSteps"] do
- refuelIfNeeded(30)
- if haveRednet then
- chunkload()
- end
- if (config["pathDirection"] == "down") then
- -- Starts 1 above first step
- moves.down()
- moves.digTunnelSlice(tonumber(config["stairHeight"]))
- if config["safeTunnel"] == "yes" then
- sleep(1)
- moves.secureTunnelSlice(tonumber(config["stairHeight"]))
- end
- checkTorch()
- moves.forward()
- end
- if (config["pathDirection"] == "up") then
- -- Starts on first step.
- moves.digTunnelSlice(tonumber(config["stairHeight"]))
- if config["safeTunnel"] == "yes" then
- sleep(1)
- moves.secureTunnelSlice(tonumber(config["stairHeight"]))
- end
- checkTorch()
- moves.up()
- moves.forward()
- end
- if (config["pathDirection"] == "level") then
- -- Starts the ground
- moves.digTunnelSlice(tonumber(config["tunnelHeight"]))
- if config["safeTunnel"] == "yes" then
- sleep(1)
- moves.secureTunnelSlice(tonumber(config["tunnelHeight"]))
- end
- checkTorch()
- -- Mineshaft mode, place redstone torches every 4 spots to indicate branch locations.
- checkRedstoneTorch()
- moves.forward()
- end
- local remaining = config["maxSteps"] - spaces
- updateLine(remaining.."/"..config["maxSteps"])
- local inv = scanInventory()
- if (inv.empty == 0) then
- dropCommonItems(inv)
- end
- spaces = spaces + 1
- updateContinue("digtunnel",remaining)
- end
- updateContinue("digtunnel",nil)
Advertisement
Add Comment
Please, Sign In to add comment