Fix syntax, fix startfuel

This commit is contained in:
Dominic Zimmer 2020-07-09 10:18:17 +02:00
parent cfb3074158
commit 41a60f00a3

View File

@ -1,6 +1,5 @@
args = {...} args = {...}
x, z, direction = 0, 0, 0 x, z, direction = 0, 0, 0
startfuel = nil
turtlestate = { turtlestate = {
name = os.getComputerLabel(), name = os.getComputerLabel(),
id = os.getComputerID(), id = os.getComputerID(),
@ -106,7 +105,7 @@ function moveSafe(moveAction, inspectAction, digAction)
if block["name"]:lower():find("turtle") then if block["name"]:lower():find("turtle") then
-- turtle in front of me. lets wait for it to move -- turtle in front of me. lets wait for it to move
sleep(0.6) sleep(0.6)
elseif block["name"]:lower().find("water") or block["name"]:lower().find("lava") then elseif block["name"]:lower():find("water") or block["name"]:lower():find("lava") then
if moveAction() then if moveAction() then
break break
else else
@ -636,6 +635,7 @@ function doRefuel2()
sleep(5) sleep(5)
end end
end end
updateState({ startfuel = turtle.getFuelLevel() })
end end
slots = { {7,-6}, {7, -7}, {7, -8}, {7,-5}, {7,-4} } slots = { {7,-6}, {7, -7}, {7, -8}, {7,-5}, {7,-4} }
@ -663,7 +663,7 @@ function reportDuty2()
end end
rednet.open("top") rednet.open("top")
id = turtlestate["job"] id = turtlestate["job"]
fuelconsumed = startfuel - turtle.getFuelLevel() fuelconsumed = turtlestate["startfuel"] - turtle.getFuelLevel()
turtlestate["fuel"] = fuelconsumed turtlestate["fuel"] = fuelconsumed
rednet.broadcast("syn") rednet.broadcast("syn")
@ -685,7 +685,7 @@ function turtleAI2()
local job = enqueueForJob2() local job = enqueueForJob2()
turtlestate["job"] = job turtlestate["job"] = job
doRefuel2() doRefuel2()
turtlestate["startfuel"] = turtle.getFuelLevel() --turtlestate["startfuel"] = turtle.getFuelLevel()
goToJob2(job) goToJob2(job)
digShaft() digShaft()
goToUnloading() goToUnloading()