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)
|
function Controller:doAction(id, message, protocol)
|
||||||
self:sendMessage(id, message, protocol)
|
self:sendMessage(id, message, protocol)
|
||||||
local id2, message2
|
local id2, message2, protocol2
|
||||||
repeat
|
repeat
|
||||||
id2, message2 = rednet.receive()
|
id2, message2, protocol2 = rednet.receive()
|
||||||
until id2 == id
|
until id2 == id
|
||||||
return message2 == "confirm", message2
|
return protocol2 == "confirm", message2
|
||||||
end
|
end
|
||||||
|
|
||||||
function Controller:setSlaveID(id)
|
function Controller:setSlaveID(id)
|
||||||
@ -76,6 +76,7 @@ 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()
|
||||||
@ -95,16 +96,18 @@ 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()
|
||||||
self.turtleStatus = "checking tree"
|
local s, fuelLevel = self:doAction(self.slaveID, "getFuelLevel")
|
||||||
local s, fuelLevel = self:doAction("getFuelLevel")
|
|
||||||
if(s == true) then
|
if(s == true) then
|
||||||
self.turtleFuelLevel = fuelLevel
|
self.turtleFuelLevel = fuelLevel
|
||||||
end
|
end
|
||||||
@ -120,7 +123,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, self.turtleFuelLevel)
|
self.monitor:setStatus(line, "fuel Level:" .. self.turtleFuelLevel)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -388,4 +388,18 @@ function Wood:assertInvUpdate(update)
|
|||||||
if update == true then
|
if update == true then
|
||||||
self:updateInv()
|
self:updateInv()
|
||||||
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
|
end
|
@ -34,6 +34,9 @@ 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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user