From 070f33ac80acae6b5744ca389a40d489302f0827 Mon Sep 17 00:00:00 2001 From: manuel Date: Fri, 13 Jan 2023 20:05:49 +0000 Subject: [PATCH] Update 'Controller/CropController.lua' --- Controller/CropController.lua | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Controller/CropController.lua b/Controller/CropController.lua index 1139560..cd892cc 100644 --- a/Controller/CropController.lua +++ b/Controller/CropController.lua @@ -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 \ No newline at end of file