From 86fbf428b270e1fbdb315546f804a180a0696e5a Mon Sep 17 00:00:00 2001 From: Kai Vogelgesang Date: Wed, 8 Jul 2020 13:04:31 +0200 Subject: [PATCH] Debug --- kai/woodfarm.lua | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/kai/woodfarm.lua b/kai/woodfarm.lua index a4993c4..86f4f88 100644 --- a/kai/woodfarm.lua +++ b/kai/woodfarm.lua @@ -43,6 +43,12 @@ local BACKUP_SAP_SLOT_TARGET_COUNT = 20 -- Should be enough even if every tree is fully grown local FUEL_LEVEL_TARGET = 1000 +local function breakpoint() + write("Enter to step ") + repeat e, d = os.pullEvent() until e == "key" and d == 257 + print("(OK)") +end + local function calculate_tree_position(row_index, tree_index) local x = (row_index - 1) * 5 @@ -105,6 +111,10 @@ local state_machine = { local x, z = calculate_tree_position(T.state.current_row, T.state.current_tree) local o + if T.state.current_tree > 12 then + breakpoint() + end + if T.state.current_row ~= 1 and T.state.current_tree == 1 then -- we just turned towards a new row and are approaching in positive x direction x = x - 1 @@ -139,7 +149,6 @@ local state_machine = { ["ASCEND_TREE"] = function() local success, data = turtle.inspectUp() - print("inspect", success, data) if not success and T.state.y < TREE_MAX_Y - 1 then -- probably reset after chopping a block T.up() @@ -147,15 +156,14 @@ local state_machine = { while true do local success, data = turtle.inspectUp() - print("inspect", success, data) if not success or data.name ~= LOG_NAME then - print("chopped all the wood") -- chopped all the wood break end turtle.digUp() if T.state.y == TREE_MAX_Y - 1 then print("below last log") + breakpoint() -- we are below the last log, no need to move up break end @@ -251,8 +259,4 @@ while true do print("State: " .. T.state.current_state) print("Pos: " .. T.state.x .. "," .. T.state.z .. "(" .. T.getOrientation() .. ")") T.state.current_state = state_machine[T.state.current_state]() - - write("Enter to step ") - repeat e, d = os.pullEvent() until e == "key" and d == 257 - print("(OK)") end \ No newline at end of file