Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
dyphire committed Apr 11, 2024
1 parent 01a02ba commit 4afe4fe
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions scripts/uosc/elements/CycleButton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ function CycleButton:init(id, props)
end

local function handle_change(name, value)
-- Removes unnecessary floating point digits from values like `2.00000`.
-- This happens when observing properties like `speed`.
if type(value) == 'string' and string.match(value, '^[%+%-]?%d+%.%d+$') then
value = tonumber(value)
end

value = type(value) == 'boolean' and (value and 'yes' or 'no') or tostring(value or '')
local index = itable_find(self.states, function(state) return state.value == value end)
self.current_state_index = index or 1
Expand Down

0 comments on commit 4afe4fe

Please sign in to comment.