Compare commits

..

No commits in common. "ddf13c76e4d7a457fb942f9759143eddce8b5f54" and "117b22041d954f6ce422b4d54e6b1d72e5458657" have entirely different histories.

3 changed files with 7 additions and 27 deletions

View File

@ -29,11 +29,11 @@ end
function Controller:doAction(id, message, protocol) function Controller:doAction(id, message, protocol)
self:sendMessage(id, message, protocol) self:sendMessage(id, message, protocol)
local id2, message2, protocol2 local id2, message2
repeat repeat
id2, message2, protocol2 = rednet.receive() id2, message2 = rednet.receive()
until id2 == id until id2 == id
return protocol2 == "confirm", message2 return message2 == "confirm", message2
end end
function Controller:setSlaveID(id) function Controller:setSlaveID(id)
@ -76,7 +76,6 @@ end
function Controller:autoWood() function Controller:autoWood()
self.stop = false self.stop = false
while(self.stop == false) do while(self.stop == false) do
self.turtleStatus = "checking tree"
self:updateFuelLevel() self:updateFuelLevel()
self:updateDisplay(4) self:updateDisplay(4)
local update = self:updateTreeStatus() local update = self:updateTreeStatus()
@ -96,18 +95,16 @@ function Controller:autoWood()
self:updateDisplay(4) self:updateDisplay(4)
self:doAction(self.slaveID, "cutTree") self:doAction(self.slaveID, "cutTree")
self.turtleStatus = "planting tree" self.turtleStatus = "planting tree"
self:updateFuelLevel() self:updateFuelLevel
self:updateDisplay(4) self:updateDisplay(4)
self:doAction(self.slaveID, "plantTree") self:doAction(self.slaveID, "plantTree")
end end
if self.turtleFuelLevel < 1000 then
self:doAction(self.slaveID, "refuel")
end
end end
end end
function Controller:updateFuelLevel() function Controller:updateFuelLevel()
local s, fuelLevel = self:doAction(self.slaveID, "getFuelLevel") self.turtleStatus = "checking tree"
local s, fuelLevel = self:doAction("getFuelLevel")
if(s == true) then if(s == true) then
self.turtleFuelLevel = fuelLevel self.turtleFuelLevel = fuelLevel
end end
@ -123,7 +120,7 @@ end
function Controller:displayFuelLevel(line) function Controller:displayFuelLevel(line)
if(self.monitor.sb.lines[line] ~= self.turtleFuelLevel) then if(self.monitor.sb.lines[line] ~= self.turtleFuelLevel) then
self.monitor:setStatus(line, "fuel Level:" .. self.turtleFuelLevel) self.monitor:setStatus(line, self.turtleFuelLevel)
end end
end end

View File

@ -389,17 +389,3 @@ function Wood:assertInvUpdate(update)
self:updateInv() self:updateInv()
end end
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

View File

@ -34,9 +34,6 @@ function answer(message, id)
end end
elseif(message == "getFuelLevel") then elseif(message == "getFuelLevel") then
rednet.send(id, tostring(tree:getFuelLevel()), "confirm") rednet.send(id, tostring(tree:getFuelLevel()), "confirm")
elseif(message == "refuel") then
tree:refuel()
rednet.send(id, "refueled", "confirm")
end end
rednet.send(id, "could not resolve message", "error") rednet.send(id, "could not resolve message", "error")
end end