fix(nature/greenhouse): dont redraw if scroll pos stays the same

pull/240/head
sammyette 2023-02-18 18:58:44 -04:00
parent bb9a6fe39e
commit 8b5b9b3c1c
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 3 additions and 0 deletions

View File

@ -35,11 +35,14 @@ function Greenhouse:draw()
end end
function Greenhouse:scroll(direction) function Greenhouse:scroll(direction)
local oldOffset = self.offset
if direction == 'down' then if direction == 'down' then
self.offset = math.min(self.offset + 1, #self.lines) self.offset = math.min(self.offset + 1, #self.lines)
elseif direction == 'up' then elseif direction == 'up' then
self.offset = math.max(self.offset - 1, 1) self.offset = math.max(self.offset - 1, 1)
end end
if self.offset ~= oldOffset then self:draw() end
end end
function Greenhouse:update() function Greenhouse:update()