diff --git a/src/main/lib/basic-functions.lua b/src/main/lib/basic.lua similarity index 100% rename from src/main/lib/basic-functions.lua rename to src/main/lib/basic.lua diff --git a/src/main/programs/turtle-miner-stupidExcavate.lua b/src/main/programs/turtle-miner-stupidExcavate.lua new file mode 100644 index 0000000..fd45272 --- /dev/null +++ b/src/main/programs/turtle-miner-stupidExcavate.lua @@ -0,0 +1,52 @@ +basic = require("lib.basic") + +local function setState() + basic.writeToFile("main/files/state-turtle-miner-stupidExcavate.txt", textutils.serialize(state)) +end + +local function getState() + state = basic.readFileAll("main/files/state-turtle-miner-stupidExcavate.txt") + state = textutils.unserialize(state) + return state +end + + +function init(height) + local height = read() -- zb 172 + local a = math.random(4,8) +end + + +local function digLayer(a) + for i=1, a do + for j=1, a do + turtle.digDown() + turtle.forward() + end + if i%2==0 then + turtle.turnRight() + turtle.forward() + turtle.turnRight() + else + turtle.turnLeft() + turtle.forward() + turtle.turnLeft() + end + end + + if i%2==0 then + turtle.turnRight() + else + turtle.turnLeft() + end +end + + +local function digComplete(a, height) + for i=1, height do + digLayer(a) + turtle.down() + end +end + +digComplete(4, 4) \ No newline at end of file diff --git a/src/main/programs/turtle-miner.lua b/src/main/programs/turtle-miner.lua index 07cc4d9..166207d 100755 --- a/src/main/programs/turtle-miner.lua +++ b/src/main/programs/turtle-miner.lua @@ -1,4 +1,4 @@ -basic_functions = require("lib.basic-functions") +basic = require("lib.basic") ore_list = { [0] = "minecraft:gold_ore", @@ -33,32 +33,25 @@ throw_away_list = { [7] = "minecraft:netherrack", } -local function get_fuel_level() - fuel_level = turtle.getFuelLevel() - return fuel_level -end - - - local function save_state() - basic_functions.write_to_file("bos/files/turtle-state.txt", textutils.serialize(state)) + basic.write_to_file("main/files/turtle-state.txt", textutils.serialize(state)) end local function get_state() - if not fs.exists "bos/files/turtle-state.txt" then + if not fs.exists "main/files/turtle-state.txt" then turtle_state = {} - turtle_state["script"] = "bos/turtle-miner.lua" + turtle_state["script"] = "main/turtle-miner.lua" turtle_state["info"] = "" - turtle_state["fuel_level"] = get_fuel_level() + turtle_state["fuel_level"] = turtle.getFuelLevel() turtle_state["data_goal_rows"] = 0 turtle_state["data_goal_path_progress"] = 0 turtle_state["data_current_row"] = 0 turtle_state["data_current_path_progress"] = 0 - basic_functions.write_to_file("bos/files/turtle-state.txt", textutils.serialize(turtle_state)) + basic.write_to_file("main/files/turtle-state.txt", textutils.serialize(turtle_state)) else - turtle_state = basic_functions.read_file_all("bos/files/turtle-state.txt") + turtle_state = basic.read_file_all("main/files/turtle-state.txt") turtle_state = textutils.unserialize(turtle_state) end return turtle_state @@ -220,7 +213,7 @@ function mine_forward(distance) --save path progress state["data_current_path_progress"] = i+1 - state["fuel_level"] = get_fuel_level() + state["fuel_level"] = turtle.getFuelLevel() save_state(state) end print("row: " .. state["data_current_row"]+1 .. "/" .. state["data_goal_rows"] .. ", path_progress: " .. state["data_current_path_progress"]+1 .. "/" .. state["data_goal_path_progress"])