Debug
This commit is contained in:
parent
fc0b34731f
commit
86fbf428b2
@ -43,6 +43,12 @@ local BACKUP_SAP_SLOT_TARGET_COUNT = 20
|
|||||||
-- Should be enough even if every tree is fully grown
|
-- Should be enough even if every tree is fully grown
|
||||||
local FUEL_LEVEL_TARGET = 1000
|
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 function calculate_tree_position(row_index, tree_index)
|
||||||
|
|
||||||
local x = (row_index - 1) * 5
|
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 x, z = calculate_tree_position(T.state.current_row, T.state.current_tree)
|
||||||
local o
|
local o
|
||||||
|
|
||||||
|
if T.state.current_tree > 12 then
|
||||||
|
breakpoint()
|
||||||
|
end
|
||||||
|
|
||||||
if T.state.current_row ~= 1 and T.state.current_tree == 1 then
|
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
|
-- we just turned towards a new row and are approaching in positive x direction
|
||||||
x = x - 1
|
x = x - 1
|
||||||
@ -139,7 +149,6 @@ local state_machine = {
|
|||||||
|
|
||||||
["ASCEND_TREE"] = function()
|
["ASCEND_TREE"] = function()
|
||||||
local success, data = turtle.inspectUp()
|
local success, data = turtle.inspectUp()
|
||||||
print("inspect", success, data)
|
|
||||||
if not success and T.state.y < TREE_MAX_Y - 1 then
|
if not success and T.state.y < TREE_MAX_Y - 1 then
|
||||||
-- probably reset after chopping a block
|
-- probably reset after chopping a block
|
||||||
T.up()
|
T.up()
|
||||||
@ -147,15 +156,14 @@ local state_machine = {
|
|||||||
|
|
||||||
while true do
|
while true do
|
||||||
local success, data = turtle.inspectUp()
|
local success, data = turtle.inspectUp()
|
||||||
print("inspect", success, data)
|
|
||||||
if not success or data.name ~= LOG_NAME then
|
if not success or data.name ~= LOG_NAME then
|
||||||
print("chopped all the wood")
|
|
||||||
-- chopped all the wood
|
-- chopped all the wood
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
turtle.digUp()
|
turtle.digUp()
|
||||||
if T.state.y == TREE_MAX_Y - 1 then
|
if T.state.y == TREE_MAX_Y - 1 then
|
||||||
print("below last log")
|
print("below last log")
|
||||||
|
breakpoint()
|
||||||
-- we are below the last log, no need to move up
|
-- we are below the last log, no need to move up
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -251,8 +259,4 @@ while true do
|
|||||||
print("State: " .. T.state.current_state)
|
print("State: " .. T.state.current_state)
|
||||||
print("Pos: " .. T.state.x .. "," .. T.state.z .. "(" .. T.getOrientation() .. ")")
|
print("Pos: " .. T.state.x .. "," .. T.state.z .. "(" .. T.getOrientation() .. ")")
|
||||||
T.state.current_state = state_machine[T.state.current_state]()
|
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
|
end
|
Loading…
Reference in New Issue
Block a user