Update 'Controller/CropController.lua'
This commit is contained in:
		| @@ -6,6 +6,7 @@ function CropController:new(t) | |||||||
|     setmetatable(t, self) |     setmetatable(t, self) | ||||||
|     self.__index = self |     self.__index = self | ||||||
|     t.matrix = {} |     t.matrix = {} | ||||||
|  |     t.stats = {} | ||||||
|     return t |     return t | ||||||
| end | end | ||||||
|  |  | ||||||
| @@ -150,10 +151,27 @@ function CropController:harvest() | |||||||
|     self:doAction(self.slaveID, "harvest") |     self:doAction(self.slaveID, "harvest") | ||||||
|     local s, duration = self:doAction(self.slaveID, "getLastHarvestDuration") |     local s, duration = self:doAction(self.slaveID, "getLastHarvestDuration") | ||||||
|     if s == true then |     if s == true then | ||||||
|         self.lastHarvestDuration = duration |         self.stats.lastHarvestDuration = duration | ||||||
|     end |     end | ||||||
|     local s, yield = self:doAction(self.slaveID, "getLastYield") |     local s, yield = self:doAction(self.slaveID, "getLastYield") | ||||||
|     if s == true then |     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 | ||||||
| end | end | ||||||
		Reference in New Issue
	
	Block a user