diff --git a/dominic/canemine.lua b/dominic/canemine.lua index 8449f35..7e25720 100644 --- a/dominic/canemine.lua +++ b/dominic/canemine.lua @@ -39,22 +39,22 @@ function ithSpot(i) end end -function digTo(x, z) - print("Digging to rel. coord ("..tostring(x)..", "..tostring(z)..")") - while z > 0 do - turtle.dig() - turtle.forward() - turtle.digUp() - z = z - 1 - end - turtle.turnRight() - while x > 0 do - turtle.dig() - turtle.forward() - turtle.digUp() - x = x - 1 - end -end +-- function digTo(x, z) +-- print("Digging to ("..tostring(x)..", "..tostring(z)..")") +-- while z > 0 do +-- turtle.dig() +-- turtle.forward() +-- turtle.digUp() +-- z = z - 1 +-- end +-- turtle.turnRight() +-- while x > 0 do +-- turtle.dig() +-- turtle.forward() +-- turtle.digUp() +-- x = x - 1 +-- end +-- end -- If the block in front of the turtle is desired, take it. function grabOres() @@ -115,9 +115,7 @@ function digShaft() selectCobble() turtle.placeUp() turtle.down() - print("Starting to dig shaft") - depth = digDeep(turtle.down, turtle.digDown, turtle.inspectDown, 3) - print("Dug the first shaft (depth = "..tostring(depth)..")") + depth = digDeep(turtle.down, turtle.digDown, turtle.inspectDown, -1) turtle.turnLeft() digDeep(turtle.up, noop, noop, depth) turtle.turnLeft() @@ -217,7 +215,7 @@ function reportDuty(id) moveSafeForward() moveSafeForward() rednet.open("bottom") - rednet.broadcast(tostring(id), "jobcomplete") + rednet.broadcast(tostring(id), "jobs") while true do sender, message, proto = rednet.receive("jobcomplete") if message == "thanks" then @@ -262,14 +260,26 @@ function enqueueTurtle() turtle.turnLeft() end +function doRefuel() + turtle.select(1) + while turtle.getFuelLevel() < 1500 do + turtle.suck(1) + turtle.refuel(1) + end +end + function goToJob() moveSafeForward() + turtle.turnRight() + doRefuel() + turtle.turnLeft() moveSafeForward() moveSafeForward() moveSafeForward() end function waitForJob() + print("Waiting for job...") while true do status, block = turtle.inspectDown() if status and block["name"] == "computercraft:wired_modem_full" then @@ -279,9 +289,11 @@ function waitForJob() end end rednet.open("bottom") - rednet.broadcast("Gimme gimme gimme", "needajob") + rednet.broadcast("gibjob", "jobs") sender, message, proto = rednet.receive("newjob") - return tonumber(message) + job = tonumber(message) + print("Received job "..tostring(job)) + return job end function emptyToBarrel()