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 playmatAPI = require("playermat/PlaymatApi")
local matColor local matColor, handColor, loopId, hovering
local handColor
local loopId
function onLoad() function onLoad()
local buttonParamaters = {} local buttonParamaters = {}
@ -48,12 +46,18 @@ function onDrop() updateColors() end
-- toggles counting method briefly -- toggles counting method briefly
function onObjectHover(hover_color, obj) function onObjectHover(hover_color, obj)
-- only continue if correct player hovers over "self" -- 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 -- stop loop, toggle "des" and displayed value briefly, then start new loop after 2s
Wait.stop(loopId) Wait.stop(loopId)
updateValue(true) 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 end
-- updates the matcolor and handcolor variable -- updates the matcolor and handcolor variable
@ -99,7 +103,7 @@ function updateValue(toggle)
if obj.tag == "Card" then size = size + 1 end if obj.tag == "Card" then size = size + 1 end
end end
end end
-- update button label and color -- update button label and color
self.editButton({ index = 0, font_color = des and "Green" or "White", label = size }) self.editButton({ index = 0, font_color = des and "Green" or "White", label = size })
end end