Improving onClick/update mocks

Making on to off to on and on to off to idle wait for progress to finish
This commit is contained in:
Gabriel Moreira Minossi 2021-01-10 14:05:39 -03:00
parent 510846d1ec
commit f84c082d47
2 changed files with 17 additions and 6 deletions

View File

@ -26,7 +26,7 @@ local colors = {
lightGray = 0xD3D3D3,
darkGray = 0xA9A9A9,
darkSlateGrey = 0x2F4F4F,
notBlack = 0x101020,
notBlack = 0x181828,
black = 0x000000
}

View File

@ -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