diff --git a/src/accessories/HandHelper.ttslua b/src/accessories/HandHelper.ttslua index 3137a966..21e2e586 100644 --- a/src/accessories/HandHelper.ttslua +++ b/src/accessories/HandHelper.ttslua @@ -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 @@ -99,7 +103,7 @@ function updateValue(toggle) if obj.tag == "Card" then size = size + 1 end end end - + -- update button label and color self.editButton({ index = 0, font_color = des and "Green" or "White", label = size }) end