Track ores
This commit is contained in:
parent
620ffc7ace
commit
a6948364a0
@ -6,7 +6,8 @@ turtlestate = {
|
|||||||
id = os.getComputerID(),
|
id = os.getComputerID(),
|
||||||
fuel = "",
|
fuel = "",
|
||||||
state = "init",
|
state = "init",
|
||||||
job = nil
|
job = nil,
|
||||||
|
ores = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function noop() end
|
function noop() end
|
||||||
@ -121,6 +122,12 @@ end
|
|||||||
function grabOres()
|
function grabOres()
|
||||||
local status, block = turtle.inspect()
|
local status, block = turtle.inspect()
|
||||||
if status and block["name"]:lower():find("ore") then
|
if status and block["name"]:lower():find("ore") then
|
||||||
|
ore = block["name"]:lower()
|
||||||
|
if turtlestates["ores"][ore] then
|
||||||
|
turtlestates["ores"][ore] = turtlestates["ores"][ore] + 1
|
||||||
|
else
|
||||||
|
turtlestates["ores"][ore] = 1
|
||||||
|
end
|
||||||
turtle.dig()
|
turtle.dig()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -187,7 +194,7 @@ function digShaft()
|
|||||||
--turtle.placeUp()
|
--turtle.placeUp()
|
||||||
moveSafe(turtle.down, turtle.inspectDown, turtle.digDown)
|
moveSafe(turtle.down, turtle.inspectDown, turtle.digDown)
|
||||||
--turtle.down()
|
--turtle.down()
|
||||||
depth = digDeep(turtle.down, turtle.digDown, turtle.inspectDown, -1)
|
depth = digDeep(turtle.down, turtle.digDown, turtle.inspectDown, 3)
|
||||||
turtle.turnLeft()
|
turtle.turnLeft()
|
||||||
digDeep(turtle.up, noop, noop, depth)
|
digDeep(turtle.up, noop, noop, depth)
|
||||||
turtle.turnLeft()
|
turtle.turnLeft()
|
||||||
@ -644,7 +651,7 @@ function reportDuty2()
|
|||||||
end
|
end
|
||||||
rednet.open("top")
|
rednet.open("top")
|
||||||
id = turtlestate["job"]
|
id = turtlestate["job"]
|
||||||
fuelconsumed = turtle.getFuelLevel() - startfuel
|
fuelconsumed = startfuel - turtle.getFuelLevel()
|
||||||
turtlestate["fuel"] = fuelconsumed
|
turtlestate["fuel"] = fuelconsumed
|
||||||
rednet.broadcast(tostring(id), "jobs")
|
rednet.broadcast(tostring(id), "jobs")
|
||||||
sleep(0.6)
|
sleep(0.6)
|
||||||
@ -660,10 +667,13 @@ function reportDuty2()
|
|||||||
sleep(1)
|
sleep(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
for k, v in pairs(turtlestate["ores"]) do
|
||||||
|
print(k,v)
|
||||||
|
end
|
||||||
|
exit()
|
||||||
--print("Proto: Received thanks")
|
--print("Proto: Received thanks")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function turtleAI2()
|
function turtleAI2()
|
||||||
while true do
|
while true do
|
||||||
local job = enqueueForJob2()
|
local job = enqueueForJob2()
|
||||||
|
Loading…
Reference in New Issue
Block a user