Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script by Savage_Me55iah of CraftAU.com.au and Nuqube.co --
- local version, pastebinCode = "v0.2", "Htf7LraY"
- --Other Savage_Me55iah scripts @ http://pastebin.com/u/Savage_Me55iah
- -- INSTRUCTIONS ON USE --
- -- Instruction video on http://youtube.com/savagemessiah5
- -- Confirmed working turtle chunk loader mod: chunkyperipherals
- -- Contact Savage_Me55iah @ CraftAU.com.au or Nuqube.co or http://www.computercraft.info/forums2/ with suggestions/fixes/bugs
- -- CHANGELOG --
- -- V 0.1 - Working
- -- V 0.2 - Mining between non flat bedrock
- -- V 0.2 - Auto creating and removing startup script
- -- YET TO BE IMPLEMENTED --
- -- Dumping of non whitelist materials
- -- Running into indestructible blocks horizontally
- -- Pausing & restarting on storage chest full
- -- Improving emergency return to surface situations
- -- Rednet broadcast positioning data if available
- -- Faster refueling and storage coding
- -- GUI on script start
- -- Rednet remote return/pause/resume
- -- UPDATER --
- local tArgs = {...}
- local update = tostring(tArgs[1]) or nil
- if update == "update" then
- print("UPDATING")
- shell.run("pastebin get "..pastebinCode.." update")
- if fs.exists("update") then
- fs.delete(shell.getRunningProgram())
- fs.copy("update", shell.getRunningProgram())
- fs.delete("update")
- print("UPDATE SUCCESS")
- else
- print("UPDATE FAILED")
- end
- sleep(2)
- os.reboot()
- end
- -- SETUP --
- label = os.getComputerLabel() or false
- if label == false then
- print("Please Type label here: ")
- os.setComputerLabel(tostring(read()))
- end
- function boolean_check(params)
- local answer = nil
- if tostring(params) == "true" then
- answer = true
- else
- answer = false
- end
- return answer
- end
- local settings_file = "config"
- local settings_template = [[-- adjust these configuration options as necessary.
- -- IMPORTANT!, API won't load if there are spaces in the values
- COMPUTER_LABEL = "${label}"
- COMPUTER_ID = ${id}
- USE_WHITELIST = "${use_whitelist}"
- DUMP_NON_WHITELIST = "${dump_non_whitelist}"
- ENDERCHEST_STORAGE = "${enderchest_storage}"
- ENDERCHEST_FUEL = "${enderchest_fuel}"
- FLAT_BEDROCK = "${flat_bedrock}"
- SIZE_X = ${size_x}
- SIZE_Z = ${size_z}
- RESTART_TIME = ${restart_time}
- RESTART_TIME_INT = ${restart_time_int}
- ]]
- local function interpolate(s, params)
- return s:gsub('($%b{})', function(w) return params[w:sub(3, -2)] or w end)
- end
- do
- save_settings = function()
- local filehandler = fs.open(tostring(settings_file), "w")
- if tostring(CONFIG) == "nil" then
- settings = {
- label = os.getComputerLabel(),
- id = os.getComputerID(),
- use_whitelist = "true",
- dump_non_whitelist = "false",
- enderchest_storage = "true",
- enderchest_fuel = "true",
- flat_bedrock = "true",
- size_x = 16,
- size_z = 15,
- restart_time = 60,
- restart_time_int = 5
- }
- else
- settings = {
- label = CONFIG.COMPUTER_LABEL or os.getComputerLabel(),
- id = os.getComputerID(),
- use_whitelist = CONFIG.USE_WHITELIST or "true",
- dump_non_whitelist = CONFIG.DUMP_NON_WHITELIST or "false",
- enderchest_storage = CONFIG.ENDERCHEST_STORAGE or "true",
- enderchest_fuel = CONFIG.ENDERCHEST_FUEL or "true",
- flat_bedrock = CONFIG.FLAT_BEDROCK or "false",
- size_x = CONFIG.SIZE_X or 16,
- size_z = CONFIG.SIZE_Z or 15,
- restart_time = CONFIG.RESTART_TIME or 60,
- restart_time_int = CONFIG.RESTART_TIME_INT or 5
- }
- end
- filehandler.write(interpolate(settings_template, settings))
- filehandler.close()
- end
- end
- if fs.exists(settings_file) == false then
- save_settings()
- return
- else
- os.unloadAPI(settings_file)
- if os.loadAPI(settings_file) == false then print("ERROR: Could not load the settings file!") end
- CONFIG = nil
- for k, v in pairs(_G) do if k == settings_file then CONFIG = v break end end
- if CONFIG == nil then print("CONFIG came up nil") end
- end
- -- SLOTS --
- local slots = {["fuel"] = 1, ["enderchest_fuel"] = nil, ["enderchest_storage"] = nil, ["cobble"] = 2}
- if boolean_check(tostring(CONFIG.ENDERCHEST_FUEL)) then slots["enderchest_fuel"] = 2 slots["cobble"] = 3 end
- if boolean_check(tostring(CONFIG.ENDERCHEST_STORAGE)) then
- if tostring(slots["enderchest_fuel"]) ~= "nil" then slots["enderchest_storage"] = 3 slots["cobble"] = 4
- else slots["enderchest_storage"] = 2 slots["cobble"] = 3 end
- end
- local open_slot = slots["cobble"] + 1
- -- TABLES SETUP --
- whitelist, direction, curr_coords, home_coords = {}, {[1] = "north", [2] = "east", [3] = "south", [4] = "west"}, {["x"] = 0, ["z"] = 0, ["y"] = 0, ["dir"] = 1, ["operation"] = nil, ["operating"] = false, ["layer"] = 1}, {["x"] = 0, ["z"] = 0, ["y"] = 0, ["dir"] = 1}
- do whitelist_add = function(...) local params = {...} for k,v in pairs(params) do table.insert(whitelist, v) end end end
- whitelist_add("gold", "iron", "coal", "lapis", "diamond", "redstone", "emerald", "soul_sand", "glowstone", "quartz", "end", "mossy", "obsidian", "clay", "essence", "crystal", "amethyst", "ruby", "peridot", "topaz", "tanzanite", "malachite", "sapphire", "amber", "copper", "tin", "apatite", "ore", "iridium", "searedbrick", "biomeblock", "moonblock", "asteriodsblock", "mars", "uran", "lead", "mariculture:rocks", "forestry:resources")
- -- MOVEMENT FUNCTIONS --
- local store = nil
- do
- inspect = function(params_dir, params_check)
- local answer, detail = false, {}
- if params_dir == "down" then detail = {turtle.inspectDown()}
- elseif params_dir == "up" then detail = {turtle.inspectUp()}
- elseif params_dir == "forward" then detail = {turtle.inspect()}
- end
- if tostring(detail[2]["name"]) ~= "nil" then
- if tostring(string.find(detail[2]["name"]:lower(), tostring(params_check))) ~= "nil" then answer = true end
- end
- return answer
- end
- coord = function(params)
- if params == "save" then local fh = fs.open("coords", 'w') fh.write(textutils.serialize(curr_coords)) fh.close()
- elseif params == "load" and boolean_check(fs.exists("coords")) then local fh = fs.open("coords", 'r') curr_coords = textutils.unserialize(fh.readAll()) fh.close() end
- end
- coord_update = function(params_dir)
- if params_dir == "forward" then
- if curr_coords["dir"] == 1 then curr_coords["z"] = curr_coords["z"] + 1
- elseif curr_coords["dir"] == 3 then curr_coords["z"] = curr_coords["z"] - 1
- elseif curr_coords["dir"] == 2 then curr_coords["x"] = curr_coords["x"] + 1
- elseif curr_coords["dir"] == 4 then curr_coords["x"] = curr_coords["x"] - 1
- end
- elseif params_dir == "back" then
- if curr_coords["dir"] == 1 then curr_coords["z"] = curr_coords["z"] - 1
- elseif curr_coords["dir"] == 3 then curr_coords["z"] = curr_coords["z"] + 1
- elseif curr_coords["dir"] == 2 then curr_coords["x"] = curr_coords["x"] - 1
- elseif curr_coords["dir"] == 4 then curr_coords["x"] = curr_coords["x"] + 1
- end
- elseif params_dir == "up" then
- curr_coords["y"] = curr_coords["y"] + 1
- elseif params_dir == "down" then
- curr_coords["y"] = curr_coords["y"] - 1
- end
- if params_dir ~= "forward" and params_dir ~= "back" and params_dir ~= "up" and params_dir ~= "down" and tostring(params_dir) ~= "nil" then
- curr_coords["operation"] = params_dir
- end
- term.clear() term.setCursorPos(1,1)
- print("OPERATION: "..tostring(curr_coords["operation"])) print("SUBOPERATION: "..(curr_coords["sub_op"] or "nil")) print("FUEL: "..(turtle.getFuelLevel() or nil).."/"..((tonumber(CONFIG.SIZE_X) + tonumber(CONFIG.SIZE_Z) + 256) * 2)) print("LAYERS: "..tostring(curr_coords["layer"] or nil).."/"..tostring(curr_coords["top_layer"] or nil)) print("X: "..curr_coords["x"]) print("Z: "..curr_coords["z"]) print("Y: "..curr_coords["y"]) print("DIRECTION: "..curr_coords["dir"])
- coord("save")
- end
- dig = function(params_dir, params_scan)
- -- curr_coords["sub_op"] = "dig" coord_update()
- local params_inspect, params_dig, params_slot = nil, nil, tonumber(turtle.getSelectedSlot())
- turtle.select(1)
- if tostring(params_dir) == "forward" then
- if boolean_check(params_scan) and turtle.detect() then
- params_inspect = {turtle.inspect()}
- for k,v in pairs(whitelist) do if tostring(string.find(params_inspect[2]["name"]:lower(), v)) ~= "nil" then params_dig = true end end
- else
- params_dig = true
- end
- if boolean_check(params_dig) then params_dig = turtle.dig() end
- elseif tostring(params_dir) == "up" then
- if boolean_check(params_scan) and turtle.detectUp() then
- params_inspect = {turtle.inspectUp()}
- for k,v in pairs(whitelist) do if tostring(string.find(params_inspect[2]["name"]:lower(), v)) ~= "nil" then params_dig = true end end
- else
- params_dig = true
- end
- if boolean_check(params_dig) then params_dig = turtle.digUp() end
- elseif tostring(params_dir) == "down" then
- if boolean_check(params_scan) and turtle.detectDown() then
- params_inspect = {turtle.inspectDown()}
- for k,v in pairs(whitelist) do if tostring(string.find(params_inspect[2]["name"]:lower(), v)) ~= "nil" then params_dig = true end end
- else
- params_dig = true
- end
- if boolean_check(params_dig) then params_dig = turtle.digDown() end
- end
- if turtle.getItemCount(15) >= 1 then store = true else store = false end
- turtle.select(params_slot)
- return params_dig
- end
- drop = function(params_dir)
- if tostring(params_dir) == "up" then turtle.dropUp()
- elseif tostring(params_dir) == "down" then turtle.dropDown()
- elseif tostring(params_dir) == "forward" then turtle.drop()
- end
- end
- place = function(params_dir, params_slot)
- local slot = tonumber(turtle.getSelectedSlot())
- turtle.select(params_slot)
- dig(params_dir, false)
- if params_dir == "forward" then turtle.place() elseif params_dir == "up" then turtle.placeUp() elseif params_dir == "down" then turtle.placeDown() end
- turtle.select(slot)
- end
- fuel = function()
- -- curr_coords["sub_op"] = "refueling" coord_update()
- local fuel_level, fuel_min, fuel_max, fueling, slot, detail = turtle.getFuelLevel() or 1, ((tonumber(CONFIG.SIZE_X) + tonumber(CONFIG.SIZE_Z) + 256) * 2), turtle.getFuelLimit(), true, tonumber(turtle.getSelectedSlot()), {turtle.inspectDown()}
- if fuel_min >= (fuel_max - 1000) then fuel_min = (fuel_max - 1000) end
- while fuel_level < fuel_min and boolean_check(fueling) and tostring(fuel_level):lower() ~= "unilimited" do
- if turtle.getItemCount(tonumber(slots["fuel"])) > 1 then
- turtle.select(slots["fuel"]) fueling = turtle.refuel(1)
- elseif turtle.getItemCount(tonumber(slots["fuel"])) == 1 and boolean_check(CONFIG.ENDERCHEST_FUEL) then
- if tostring(detail[2]["name"]) ~= "bedrock" then
- place("down", slots["enderchest_fuel"]) turtle.select(slots["fuel"]) fueling = turtle.suckDown(turtle.getItemSpace()) turtle.select(slots["enderchest_fuel"]) turtle.digDown()
- if tostring(detail[2]["name"]) ~= "minecraft:cobblestone" then place("down", slots["cobble"]) end
- turtle.select(slot)
- else
- fueling = true
- end
- elseif turtle.getItemCount(tonumber(slots["fuel"])) == 1 and not boolean_check(CONFIG.ENDERCHEST_FUEL) then
- fueling = false store = true
- end
- fuel_level = turtle.getFuelLevel() or 1
- end
- return fueling
- end
- even = function(params)
- local params_numA, params_numB, answer = params / 2, math.floor(params / 2), nil
- if tonumber(params_numA - params_numB) == 0 then answer = true else answer = false end
- return answer
- end
- turn = function(params_dir)
- if curr_coords["dir"] >= 5 then curr_coords["dir"] = 1 elseif curr_coords["dir"] <= 0 then curr_coords["dir"] = 4 end
- if tostring(params_dir) == "right" then curr_coords["dir"] = tonumber(curr_coords["dir"]) + 1 turtle.turnRight()
- elseif tostring(params_dir) == "left" then curr_coords["dir"] = tonumber(curr_coords["dir"]) - 1 turtle.turnLeft()
- end
- if curr_coords["dir"] >= 5 then curr_coords["dir"] = 1 elseif curr_coords["dir"] <= 0 then curr_coords["dir"] = 4 end
- coord_update()
- end
- move = function(params_dir, params_scan)
- local params_moved, params_dug = nil, nil
- fuel()
- if tostring(params_dir) == "left" then turn("left") elseif tostring(params_dir) == "right" then turn("right") elseif tostring(params_dir) == "reverse" then turn("right") turn("right") end
- if tostring(params_dir) == "forward" then
- if boolean_check(params_scan) then params_dug = dig("up", true) while boolean_check(params_dug) do sleep(0.2) params_dug = dig("up", false) end if inspect("up", "water") or inspect("up", "lava") then place("up", slots["cobble"]) end
- dig("down", true) if inspect("down", "water") or inspect("down", "lava") then place("down", slots["cobble"]) end end
- while boolean_check(params_moved) ~= true do params_moved = turtle.forward() if boolean_check(params_moved) ~= true then dig("forward", false) turtle.attack() end end
- if boolean_check(params_moved) then coord_update("forward") end
- elseif tostring(params_dir) == "down" then while boolean_check(params_moved) ~= true do params_moved = turtle.down() if boolean_check(params_moved) ~= true then dig("down", false) turtle.attackDown() end end if boolean_check(params_moved) then coord_update("down") end
- elseif tostring(params_dir) == "up" then while boolean_check(params_moved) ~= true do params_moved = turtle.up() if boolean_check(params_moved) ~= true then dig("up", false) turtle.attackUp() end end if boolean_check(params_moved) then coord_update("up") end
- end
- end
- coord_move = function(params_x, params_z, params_y, params_dir, params_scan)
- if tostring(params_scan) ~= "memory" then curr_coords["memory"] = {["x"] = curr_coords["x"], ["z"] = curr_coords["z"], ["y"] = curr_coords["y"], ["dir"] = curr_coords["dir"]} coord() end
- -- X, Z DIRECTIONS
- while tonumber(params_x) ~= tonumber(curr_coords["x"]) or tonumber(params_z) ~= tonumber(curr_coords["z"]) do
- local dir = nil
- if params_x < curr_coords["x"] then dir = 4
- elseif params_x > curr_coords["x"] then dir = 2
- elseif params_z > curr_coords["z"] then dir = 1
- elseif params_z < curr_coords["z"] then dir = 3
- end
- curr_coords["sub_op"] = "coord move "..params_x..":"..curr_coords["x"].." "..params_z..":"..curr_coords["z"].." "..dir coord_update()
- while dir ~= tonumber(curr_coords["dir"]) do turn("left") end
- move("forward", params_scan)
- end
- -- DIR
- while params_dir ~= curr_coords["dir"] do curr_coords["sub_op"] = "coord move turn" coord_update() turn("right") end
- -- Y DIRECTION
- while params_y ~= curr_coords["y"] do
- curr_coords["sub_op"] = "coord move Y" coord_update()
- if params_y > curr_coords["y"] then move("up", params_scan) elseif params_y < curr_coords["y"] then move("down", params_scan) end
- end
- end
- finish = function(params)
- curr_coords["sub_op"] = "finish" coord_update()
- if not params then coord_move(home_coords["x"], home_coords["z"], home_coords["y"], home_coords["dir"]) fs.delete("coords") write_startup(true) end
- curr_coords["operating"] = false fs.delete("coords") os.reboot()
- end
- emergency = function()
- curr_coords["emergency"] = true curr_coords["sub_op"] = "EMERGENCY" coord_update()
- if home_coords["y"] < curr_coords["y"] then coord_move(curr_coords["x"], curr_coords["z"], tonumber(home_coords["y"] + 5), home_coords["dir"]) local emerged = turtle.detectUp() while emerged do move("up") end end
- curr_coords["x"], curr_coords["z"], curr_coords["y"], curr_coords["dir"] = home_coords["x"], home_coords["z"], home_coords["y"], home_coords["dir"]
- coord("save") term.clear() term.setCursorPos(1,1)
- print("ERROR @ "..(curr_coords["memory"]["x"] or "nil").."-"..(curr_coords["memory"]["z"] or "nil").."-"..(curr_coords["memory"]["y"] or "nil").."-"..(curr_coords["memory"]["dir"] or "nil").."-"..(curr_coords["operation"] or "nil"))
- print(" ")
- print("CO-ORDINATES HAVE BEEN RESET TO HOME POSITION,")
- print("BREAK AND MOVE BACK TO HOME POSITION TO RESET")
- print("TYPE >CONTINUE< TO RESTART OR")
- print("TYPE >CLEAR< TO FINISH")
- print(" ")
- local result = nil
- while result ~= "continue" and result ~= "clear" do result = read():lower() end
- if result == "continue" then
- coord_move(curr_coords["x"], curr_coords["z"], curr_coords["memory"]["y"], curr_coords["dir"], "memory")
- coord_move(curr_coords["memory"]["x"], curr_coords["memory"]["z"], curr_coords["memory"]["y"], curr_coords["memory"]["dir"], "memory")
- curr_coords["emergency"] = false
- else
- finish(true)
- end
- end
- storage = function(params)
- curr_coords["sub_op"] = "STORAGE" coord_update()
- local slot = turtle.getSelectedSlot()
- if boolean_check(params) then coord_move(home_coords["x"], home_coords["z"], home_coords["y"], 3) end
- if boolean_check(store) or boolean_check(params) then
- local params_check, home, storage_dir, fuel_dir, dump_dir = inspect("forward", "chest"), false, "down", "down", "down"
- if boolean_check(CONFIG.ENDERCHEST_STORAGE) then place("down", slots["enderchest_storage"]) storage_dir, fuel_dir, dump_dir = "down", "down", "down"
- elseif params_check then home, storage_dir, fuel_dir, dump_dir = true, "forward", "up", "forward"
- elseif not boolean_check(CONFIG.ENDERCHEST_STORAGE) and not params_check then emergency() end
- if boolean_check(CONFIG.DUMP_NON_WHITELIST) then
- if dump_dir == "down" then dump_dir = "forward" elseif dump_dir == "forward" then dump_dir = "down" end
- end
- local num, detail = nil, nil
- for num=open_slot,16 do
- turtle.select(num) detail = turtle.getItemDetail() local action = nil
- if tostring(detail) ~= "nil" then
- for k,v in pairs(whitelist) do
- action = nil
- if tostring(string.find(detail["name"]:lower(), tostring(v))) ~= "nil" then action = "store"
- elseif tostring(string.find(detail["name"]:lower(), "coal")) ~= "nil" then action = "fuel_store"
- end
- if tostring(action) == "store" then drop(storage_dir)
- elseif tostring(action) == "fuel_store" then drop(fuel_dir)
- elseif tostring(action) == "nil" then drop(dump_dir)
- end
- end
- end
- end
- if fuel_dir == "up" then turtle.select(slots["fuel"]) turtle.suckUp(turtle.getItemSpace()) end
- if boolean_check(CONFIG.ENDERCHEST_STORAGE) then turtle.select(slots["enderchest_storage"]) turtle.digDown() end
- turtle.select(slot)
- end
- end
- bedrock = function(params)
- if params == "locate" or params == "down" then
- curr_coords["sub_op"] = "BEDROCK" coord_update()
- local level = nil
- while tostring(level) == "nil" do
- move("down")
- if boolean_check(inspect("down", "bedrock")) then level = true end
- end
- if params == "locate" then curr_coords["bedrock"] = curr_coords["y"] end
- elseif params == "up" then
- curr_coords["sub_op"] = "BEDROCK UP" coord_update()
- local level = false
- while not boolean_check(level) do
- move("up")
- if boolean_check(inspect("up", "cobblestone")) then level = true end
- end
- coord_update("move")
- dig("up")
- end
- end
- mining = function()
- curr_coords["sub_op"] = "MINING" coord_update()
- if tostring(curr_coords["operation"]) == "bedrock dig" and tonumber(curr_coords["layer"]) == 1 and not boolean_check(CONFIG.FLAT_BEDROCK) then coord_update("bedrock cobble") else coord_update("move") end
- if tostring(curr_coords["operation"]) == "bedrock cobble" then place("up", slots["cobble"]) coord_update("bedrock dig down") end
- if tostring(curr_coords["operation"]) == "bedrock dig down" then bedrock("down") coord_update("bedrock up") end
- if tostring(curr_coords["operation"]) == "bedrock up" then bedrock("up") end
- if tostring(curr_coords["operation"]) == "move" then move("forward", true) coord_update("memory") end
- if tostring(curr_coords["operation"]) == "memory" then curr_coords["memory"] = {["x"] = curr_coords["x"], ["z"] = curr_coords["z"], ["y"] = curr_coords["y"], ["dir"] = curr_coords["dir"]} coord_update("storage") end
- if tostring(curr_coords["operation"]) == "storage" and boolean_check(store) then storage((not boolean_check(CONFIG.ENDERCHEST_STORAGE))) if boolean_check(CONFIG.ENDERCHEST_STORAGE) then coord_update("bedrock dig") else coord_update("return") end else coord_update("bedrock dig") end
- if tostring(curr_coords["operation"]) == "return" then coord_move(home_coords["x"], home_coords["z"], curr_coords["memory"]["y"], home_coords["dir"], "memory") coord_move(curr_coords["memory"]["x"], curr_coords["memory"]["z"], curr_coords["y"], curr_coords["memory"]["dir"], "memory") coord_update("bedrock dig") end
- end
- startup = function(params)
- curr_coords["sub_op"] = "STARTUP" coord_update()
- if boolean_check(inspect("down", "chest")) then for num=2,3 do turtle.select(num) turtle.digDown() end end
- if boolean_check(curr_coords["emergency"]) then emergency() end
- if boolean_check(params) then
- coord_move(home_coords["x"], home_coords["z"], curr_coords["y"], 3)
- local confirm = false
- if inspect("forward", "cobble") then
- turn("right")
- if inspect("forward", "cobble") then confirm = true end
- elseif inspect("forward", "chest") then
- confirm = true
- end
- if not confirm then emergency() else coord_move(curr_coords["memory"]["x"], curr_coords["memory"]["z"], curr_coords["memory"]["y"], curr_coords["memory"]["dir"]) end
- else
- coord_move(tonumber(home_coords["x"]), tonumber(home_coords["z"]), tonumber(home_coords["y"]), tonumber(home_coords["dir"]))
- curr_coords["operating"] = true curr_coords["operation"] = nil
- end
- end
- write_startup = function(params)
- local file = "startup"
- if not boolean_check(params) then
- if not boolean_check(fs.exists(file)) then
- outputFile = io.open(file, "w")
- outputFile:write("shell.run(\"")
- outputFile:write(shell.getRunningProgram())
- outputFile:write("\")\n")
- outputFile:close()
- else
- local count, int = tonumber(CONFIG.RESTART_TIME), tonumber(CONFIG.RESTART_TIME_INT)
- while count >= 1 do
- term.clear() term.setCursorPos(1,2)
- print("QUARRY PROGRAM RESTARTING IN: "..count)
- print("BACKSPACE TO CANCEL, ANY KEY TO START")
- os.startTimer(int)
- local timer = {os.pullEvent()}
- if timer[1] == "timer" then count = count - int
- elseif timer[1] == "key" then
- if tonumber(timer[2]) == 14 then error() --backspace
- else count = -1 end
- end
- end
- end
- else
- fs.delete(file)
- end
- end
- end
- write_startup()
- if fs.exists("coords") then coord("load") else coord("save") end
- startup(boolean_check(curr_coords["operating"]))
- if tostring(curr_coords["operation"]) == "nil" then coord_update("start") end
- while boolean_check(curr_coords["operating"]) do
- if tostring(curr_coords["bedrock"]) == "nil" then bedrock("locate") end
- if boolean_check(CONFIG.FLAT_BEDROCK) then layer = 1 else layer = 5 end
- if tostring(curr_coords["operation"]) == "start" then coord_move(home_coords["x"], home_coords["z"], (curr_coords["bedrock"] + layer), home_coords["dir"]) coord_update("cobble") curr_coords["layer"] = 1 curr_coords["top_layer"] = (math.floor((curr_coords["bedrock"] + layer) / 3) * -1) curr_coords["columns"] = 1 curr_coords["rows"] = 1 coord("save") end
- while curr_coords["layer"] < curr_coords["top_layer"] and curr_coords["y"] < (home_coords["y"] - 3) do
- if tostring(curr_coords["operation"]) == "cobble" then
- while tonumber(curr_coords["dir"]) ~= 3 do turn("right") end place("forward", slots["cobble"])
- while tonumber(curr_coords["dir"]) ~= 4 do turn("right") end place("forward", slots["cobble"])
- while tonumber(curr_coords["dir"]) ~= 1 do turn("right") end coord_update("bedrock dig")
- end
- if curr_coords["columns"] == tonumber(CONFIG.SIZE_X) then curr_coords["columns"] = 1 end
- while curr_coords["columns"] <= tonumber(CONFIG.SIZE_X) do
- if curr_coords["rows"] == tonumber(CONFIG.SIZE_Z) then curr_coords["rows"] = 1 end
- while curr_coords["rows"] < tonumber(CONFIG.SIZE_Z) do
- mining()
- curr_coords["rows"] = curr_coords["rows"] + 1
- end
- if boolean_check(even(tonumber(curr_coords["columns"]))) and curr_coords["columns"] ~= tonumber(CONFIG.SIZE_X) then coord_update("columns shift left1") elseif not boolean_check(even(tonumber(curr_coords["columns"]))) and curr_coords["columns"] ~= tonumber(CONFIG.SIZE_X) then coord_update("columns shift right1") end
- if curr_coords["operation"] == "columns shift left1" or curr_coords["operation"] == "columns shift left2" or curr_coords["operation"] == "columns shift left3" then
- if curr_coords["operation"] == "columns shift left1" then turn("left") coord_update("columns shift left2") end
- if curr_coords["operation"] == "columns shift left2" then move("forward", true) coord_update("columns shift left3") end
- if curr_coords["operation"] == "columns shift left3" then turn("left") end
- elseif curr_coords["operation"] == "columns shift right1" or curr_coords["operation"] == "columns shift right2" or curr_coords["operation"] == "columns shift right3" then
- if curr_coords["operation"] == "columns shift right1" then turn("right") coord_update("columns shift right2") end
- if curr_coords["operation"] == "columns shift right2" then move("forward", true) coord_update("columns shift right3") end
- if curr_coords["operation"] == "columns shift right3" then turn("right") end
- end
- coord_update("bedrock dig")
- if curr_coords["rows"] == tonumber(CONFIG.SIZE_Z) then curr_coords["rows"] = 1 end
- curr_coords["columns"] = curr_coords["columns"] + 1
- end
- if curr_coords["columns"] >= tonumber(CONFIG.SIZE_X) then curr_coords["columns"] = 1 end
- if curr_coords["operation"] == "bedrock dig" then coord_update("return to shaft") end
- if curr_coords["operation"] == "return to shaft" then coord_move(home_coords["x"], home_coords["z"], curr_coords["y"], home_coords["dir"]) coord_update("next layer 1") end
- if curr_coords["operation"] == "next layer 1" then curr_coords["layer"] = (curr_coords["layer"] or 1) + 1 coord_update("next layer 2") end
- if curr_coords["operation"] == "next layer 2" then coord_move(home_coords["x"], home_coords["z"], (curr_coords["bedrock"] + layer + 3 * (curr_coords["layer"] - 1)), home_coords["dir"]) coord_update("cobble") end
- end
- storage(true)
- finish()
- end
Advertisement
Add Comment
Please, Sign In to add comment