Update 'Controller/CropController.lua'

This commit is contained in:
manuel 2023-01-14 10:27:53 +00:00
parent 4485896dc0
commit c4cd334cbe

View File

@ -195,4 +195,26 @@ function CropController:refreshDisplay()
term.setTextColour(colours.white)
local matrixHeight = #self.matrix
self:displayStats(1, matrixHeight + 4)
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