minor bugfix

This commit is contained in:
Chr1Z93 2023-02-28 15:08:05 +01:00
parent 4884899f30
commit 8ee07b2582

View File

@ -1,7 +1,5 @@
local playmatAPI = require("playermat/PlaymatApi")
local matColor
local handColor
local loopId
local matColor, handColor, loopId, hovering
function onLoad()
local buttonParamaters = {}
@ -48,12 +46,18 @@ function onDrop() updateColors() end
-- toggles counting method briefly
function onObjectHover(hover_color, obj)
-- only continue if correct player hovers over "self"
if obj ~= self or hover_color ~= handColor then return end
if obj ~= self or hover_color ~= handColor or hovering then return end
-- toggle this flag so this doesn't get executed multiple times during the delay
hovering = true
-- stop loop, toggle "des" and displayed value briefly, then start new loop after 2s
Wait.stop(loopId)
updateValue(true)
Wait.time(function() loopId = Wait.time(updateValue, 1, -1) end, 2)
Wait.time(function()
loopId = Wait.time(updateValue, 1, -1)
hovering = false
end, 1)
end
-- updates the matcolor and handcolor variable