Update 'Controller/CropController.lua'
This commit is contained in:
parent
4485896dc0
commit
c4cd334cbe
@ -196,3 +196,25 @@ function CropController:refreshDisplay()
|
|||||||
local matrixHeight = #self.matrix
|
local matrixHeight = #self.matrix
|
||||||
self:displayStats(1, matrixHeight + 4)
|
self:displayStats(1, matrixHeight + 4)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function CropController:updateTimeToHarvest(x,y)
|
||||||
|
term.clearLine(y)
|
||||||
|
term.setCursorPos(x,y)
|
||||||
|
term.write("next harvest in " .. tostring(math.ceil(self.stats["Harvest Interval"] - (os.clock() - self.lastHarvest))) .. " seconds")
|
||||||
|
end
|
||||||
|
|
||||||
|
function CropController:main()
|
||||||
|
local termWidth, termHeight = term.getSize()
|
||||||
|
local cc = CropController:new()
|
||||||
|
cc:setSlaveID(5)
|
||||||
|
cc:doAction(cc.slaveID, "init")
|
||||||
|
while true do
|
||||||
|
cc.lastHarvest = os.clock()
|
||||||
|
cc:harvest()
|
||||||
|
cc:refreshDisplay()
|
||||||
|
while self.stats["Harvest Interval"] - (os.clock() - self.lastHarvest) > 0 do
|
||||||
|
cc:updateTimeToHarvest(1, termHeight - 1)
|
||||||
|
sleep(0.5)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user