Compare commits
1 commit
7721442731
...
325cd5c7f3
Author | SHA1 | Date | |
---|---|---|---|
Théophile Bastian | 325cd5c7f3 |
|
@ -51,6 +51,11 @@ function turn_rel(dir)
|
|||
turn_abs((facing + dir) % 4)
|
||||
end
|
||||
|
||||
-- Dumps the current turtle position
|
||||
function _dump_pos()
|
||||
print("Current position: H "..height.." S "..side.." D "..depth)
|
||||
end
|
||||
|
||||
-- Updates the turtle position for a move in the given direction
|
||||
function _count_move_dir(dir)
|
||||
dir = dir % 4
|
||||
|
@ -65,21 +70,25 @@ function move_forward()
|
|||
rc, desc = turtle.forward()
|
||||
if not rc then abort("Move: "..desc) end
|
||||
_count_move_dir(facing)
|
||||
_dump_pos()
|
||||
end
|
||||
function move_back()
|
||||
rc, desc = turtle.back()
|
||||
if not rc then abort("Move: "..desc) end
|
||||
_count_move_dir(facing + 2)
|
||||
_dump_pos()
|
||||
end
|
||||
function move_up()
|
||||
rc, desc = turtle.up()
|
||||
if not rc then abort("Move: "..desc) end
|
||||
height = height + 1
|
||||
_dump_pos()
|
||||
end
|
||||
function move_down()
|
||||
rc, desc = turtle.down()
|
||||
if not rc then abort("Move: "..desc) end
|
||||
height = height - 1
|
||||
_dump_pos()
|
||||
end
|
||||
|
||||
function go_to_depth(dd)
|
||||
|
@ -163,7 +172,6 @@ function find_next_shaft()
|
|||
go_to(0, 0, 0)
|
||||
|
||||
while true do
|
||||
print("Climb")
|
||||
for hei=1,MAX_HEIGHT-1 do
|
||||
if (hei % 3) == 0 then
|
||||
if turtle.detect() then
|
||||
|
@ -186,7 +194,6 @@ function find_next_shaft()
|
|||
end
|
||||
turn_abs(0)
|
||||
|
||||
print("Down")
|
||||
for hei=MAX_HEIGHT-1,0,-1 do
|
||||
if (hei % 3) ~= 0 then
|
||||
if turtle.detect() then
|
||||
|
|
Loading…
Reference in a new issue