Syntax
This commit is contained in:
parent
86aa002444
commit
eb535fa029
@ -77,6 +77,22 @@ function iTo2Dcoords(j)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function digSafe(inspectAction, digAction)
|
||||||
|
while true do
|
||||||
|
local status, block = inspectAction()
|
||||||
|
if status then
|
||||||
|
if block["name"]:lower():find("turtle") then
|
||||||
|
-- turtle in front of me. lets wait for it to move
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
digAction()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- move safely into the direction, not hurting other turtles, but freeing the path if needed.
|
-- move safely into the direction, not hurting other turtles, but freeing the path if needed.
|
||||||
function moveSafe(moveAction, inspectAction, digAction)
|
function moveSafe(moveAction, inspectAction, digAction)
|
||||||
while true do
|
while true do
|
||||||
@ -529,6 +545,9 @@ function goToCoordXZ(targetX, targetZ, extraaction)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function digSafe(inspectAction, digAction)
|
||||||
|
end
|
||||||
|
|
||||||
function goToJob(job)
|
function goToJob(job)
|
||||||
jobX, jobZ = iTo2Dcoords(job) -- this does all the magic
|
jobX, jobZ = iTo2Dcoords(job) -- this does all the magic
|
||||||
updateState({ state = "Going on the job...", morestate = " Jobsite is at ("..tostring(jobX)..", "..tostring(jobZ)..")" })
|
updateState({ state = "Going on the job...", morestate = " Jobsite is at ("..tostring(jobX)..", "..tostring(jobZ)..")" })
|
||||||
@ -559,8 +578,11 @@ function turtleAI2()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function extraaction()
|
||||||
|
repeat sleep(0.6) until (not digSafe(turtle.inspectUp, turtle.digUp()))
|
||||||
|
end
|
||||||
-- turtleAI()
|
-- turtleAI()
|
||||||
faceDir(3)
|
faceDir(3)
|
||||||
goToCoordXZ(4, 2, noop)
|
goToCoordXZ(4, 2, extraaction)
|
||||||
goToCoordXZ(0, 0, noop)
|
goToCoordXZ(0, 0, extraaction)
|
||||||
goToCoordXZ(4, 2, noop)
|
goToCoordXZ(4, 2, extraaction)
|
||||||
|
Loading…
Reference in New Issue
Block a user