Documentation Index
Fetch the complete documentation index at: https://uat.rive.app/docs/llms.txt
Use this file to discover all available pages before exploring further.
Rive includes several built-in converters like Convert to String and Round.
Scripting lets you create your own custom converters when you need behavior that isn’t covered by the built-ins.
For background on converters and data binding, see Data Converters.
Examples
Creating a Converter
Create a new script and select Converter as the type.
Anatomy of a Converter Script
type MyConverter = {}
-- Called once when the script initializes.
function init(self: MyConverter): boolean
return true
end
-- Converts the property value.
function convert(self: MyConverter, input: DataInputs): DataOutput
local dv: DataValueNumber = DataValue.number()
if input:isNumber() then
dv.value = (input :: DataValueNumber).value + 1
else
dv.value = 0 -- 0 if input is not a number
end
return dv
end
-- For 2-way data binding, converts the target value back to the source
function reverseConvert(self: MyConverter, input: DataOutput): DataInputs
local dv: DataValueNumber = DataValue.number()
if input:isNumber() then
-- Example: Subtract 1 from the target number
dv.value = (input :: DataValueNumber).value - 1
else
dv.value = 0 -- 0 if target is not a number
end
return dv
end
-- Return a factory function that builds the converter instance.
-- Rive calls this when the script is created, passing back a table
-- containing its lifecycle functions and any default values.
return function(): Converter<MyConverter, DataValueNumber, DataValueNumber>
return {
init = init,
convert = convert,
reverseConvert = reverseConvert,
}
end
Creating a Converter using your Script
Create a new converter using your new converter script:
- In the Data panel, click the
+ button.
- Choose Converters → Script → MyConverter.
See Script Inputs.