Number Converter Script problem
I’m trying to write a converter script that produces a modulo 10 of the input number
but i keep getting the error (problems tab)
`Invalid transition databind condition: Type mismatch: Any cannot be compared with Number`
here is the code:
-- Define the script's data and inputs.
type Mod10Converter = {}
-- Types of inputs this converter accepts
type DataInputs = DataValueNumber
-- Data type this converter outputs
type DataOutput = DataValueNumber
-- Called once when the script initializes.
function init(self: Mod10Converter, context: Context): boolean
-- Return false to stop the script.
return true
end
-- Converts the value when binding from source to target.
function convert(self: Mod10Converter, input: DataInputs): DataOutput
local dv: DataValueNumber = DataValue.number()
dv.value = 0
if input:isNumber() then
local value = (input :: DataValueNumber).value
-- local mod = math.fmod(value, 10)
local mod = value % 10
if math.isfinite(mod) then
dv.value = mod
end
end
return dv
end
function reverseConvert(self: Mod10Converter, input: DataOutput): DataInputs
return input
end
-- Return a factory function that Rive uses to build the Converter instance.
return function(): Converter<Mod10Converter, DataInputs, DataOutput>
return {
init = init,
convert = convert,
reverseConvert = reverseConvert,
}
end
anyone got any idea where the problem is?
thanks in advance
PS. i’ve tried the AI chatbot, it gives me either no improvement or complete garbage