From f84c082d47932b2f361b6d3e59fa3dba76c01642 Mon Sep 17 00:00:00 2001 From: Gabriel Moreira Minossi Date: Sun, 10 Jan 2021 14:05:39 -0300 Subject: [PATCH] Improving onClick/update mocks Making on to off to on and on to off to idle wait for progress to finish --- Libraries/graphics/colors.lua | 2 +- Programs/monitor-system/init.lua | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Libraries/graphics/colors.lua b/Libraries/graphics/colors.lua index 03f72fc..eed19dd 100644 --- a/Libraries/graphics/colors.lua +++ b/Libraries/graphics/colors.lua @@ -26,7 +26,7 @@ local colors = { lightGray = 0xD3D3D3, darkGray = 0xA9A9A9, darkSlateGrey = 0x2F4F4F, - notBlack = 0x101020, + notBlack = 0x181828, black = 0x000000 } diff --git a/Programs/monitor-system/init.lua b/Programs/monitor-system/init.lua index 2f74e73..061dc24 100755 --- a/Programs/monitor-system/init.lua +++ b/Programs/monitor-system/init.lua @@ -96,24 +96,35 @@ local function updateMachineWidget(self) self.progress = self.progress + 1 if self.progress >= self.maxProgress then self.progress = 0 - self.state = states[2] self.maxProgress = 0 + self.state = states[2] end elseif self.state == states[2] then if math.random(1000) > 999 then self.state = states[1] self.maxProgress = math.random(500) end + elseif self.state == states[3] then + self.progress = self.progress + 1 + if self.progress >= self.maxProgress then + self.progress = 0 + self.maxProgress = 0 + end end end local function machineOnClick(self) - self.progress = 0 - self.maxProgress = 0 if self.state == states[1] or self.state == states[2] then self.state = states[3] - elseif self.state == states[3] or self.state == states[4] then - self.state = states[2] + elseif self.state == states[3] then + if self.progress < self.maxProgress then + self.state = states[1] + else + self.state = states[2] + end + elseif self.state == states[4] then + self.progress = 0 + self.maxProgress = 0 end end