Compare commits
10 Commits
117b22041d
...
ddf13c76e4
Author | SHA1 | Date | |
---|---|---|---|
|
ddf13c76e4 | ||
|
9ec4ba1e93 | ||
|
fd04524eaa | ||
|
7d0287121f | ||
|
84886d4d02 | ||
|
9b3f6d50ff | ||
|
bf0209b0d0 | ||
|
57b75dc948 | ||
|
2ed0c859ad | ||
|
93501adf14 |
@ -29,11 +29,11 @@ end
|
||||
|
||||
function Controller:doAction(id, message, protocol)
|
||||
self:sendMessage(id, message, protocol)
|
||||
local id2, message2
|
||||
local id2, message2, protocol2
|
||||
repeat
|
||||
id2, message2 = rednet.receive()
|
||||
id2, message2, protocol2 = rednet.receive()
|
||||
until id2 == id
|
||||
return message2 == "confirm", message2
|
||||
return protocol2 == "confirm", message2
|
||||
end
|
||||
|
||||
function Controller:setSlaveID(id)
|
||||
@ -76,6 +76,7 @@ end
|
||||
function Controller:autoWood()
|
||||
self.stop = false
|
||||
while(self.stop == false) do
|
||||
self.turtleStatus = "checking tree"
|
||||
self:updateFuelLevel()
|
||||
self:updateDisplay(4)
|
||||
local update = self:updateTreeStatus()
|
||||
@ -95,16 +96,18 @@ function Controller:autoWood()
|
||||
self:updateDisplay(4)
|
||||
self:doAction(self.slaveID, "cutTree")
|
||||
self.turtleStatus = "planting tree"
|
||||
self:updateFuelLevel
|
||||
self:updateFuelLevel()
|
||||
self:updateDisplay(4)
|
||||
self:doAction(self.slaveID, "plantTree")
|
||||
end
|
||||
if self.turtleFuelLevel < 1000 then
|
||||
self:doAction(self.slaveID, "refuel")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Controller:updateFuelLevel()
|
||||
self.turtleStatus = "checking tree"
|
||||
local s, fuelLevel = self:doAction("getFuelLevel")
|
||||
local s, fuelLevel = self:doAction(self.slaveID, "getFuelLevel")
|
||||
if(s == true) then
|
||||
self.turtleFuelLevel = fuelLevel
|
||||
end
|
||||
@ -120,7 +123,7 @@ end
|
||||
|
||||
function Controller:displayFuelLevel(line)
|
||||
if(self.monitor.sb.lines[line] ~= self.turtleFuelLevel) then
|
||||
self.monitor:setStatus(line, self.turtleFuelLevel)
|
||||
self.monitor:setStatus(line, "fuel Level:" .. self.turtleFuelLevel)
|
||||
end
|
||||
end
|
||||
|
@ -388,4 +388,18 @@ function Wood:assertInvUpdate(update)
|
||||
if update == true then
|
||||
self:updateInv()
|
||||
end
|
||||
end
|
||||
|
||||
function Wood:refuel(goBack)
|
||||
if (goBack == nil) then goBack = true end
|
||||
if(goBack == true) then
|
||||
goBack = {self.x, self.y, self.z, self.dir}
|
||||
end
|
||||
|
||||
self:clearInv("coalChest")
|
||||
turtle.select(1)
|
||||
turtle.suckDown()
|
||||
turtle.refuel()
|
||||
|
||||
self:moveTo(goBack)
|
||||
end
|
@ -34,6 +34,9 @@ function answer(message, id)
|
||||
end
|
||||
elseif(message == "getFuelLevel") then
|
||||
rednet.send(id, tostring(tree:getFuelLevel()), "confirm")
|
||||
elseif(message == "refuel") then
|
||||
tree:refuel()
|
||||
rednet.send(id, "refueled", "confirm")
|
||||
end
|
||||
rednet.send(id, "could not resolve message", "error")
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user