Update 'Controller/CropController.lua'

This commit is contained in:
manuel 2023-01-13 20:05:49 +00:00
parent e8a2105c77
commit 070f33ac80

View File

@ -6,6 +6,7 @@ function CropController:new(t)
setmetatable(t, self)
self.__index = self
t.matrix = {}
t.stats = {}
return t
end
@ -150,10 +151,27 @@ function CropController:harvest()
self:doAction(self.slaveID, "harvest")
local s, duration = self:doAction(self.slaveID, "getLastHarvestDuration")
if s == true then
self.lastHarvestDuration = duration
self.stats.lastHarvestDuration = duration
end
local s, yield = self:doAction(self.slaveID, "getLastYield")
if s == true then
self.lastYield = yield
self.stats.lastYield = yield
end
self:getMatrix()
end
function CropController:displayStats(x,y)
local keyWidth = 0
for k, v in pairs(self.stats) do
if string.len(tostring(k)) > keyWidth then
keyWidth = string.len(tostring(k))
end
end
for k, v in pairs(self.stats) do
term.setCursorPos(x, y)
term.write(tostring(k))
term.setCursorPos(x + keyWidth + 1, y)
term.write(tostring(v))
y = y + 1
end
end