diff --git a/defold-rive/api/rive.script_api b/defold-rive/api/rive.script_api index f3ec127..9f7697b 100644 --- a/defold-rive/api/rive.script_api +++ b/defold-rive/api/rive.script_api @@ -269,3 +269,26 @@ - name: value type: number|bool desc: The value of the input + +#***************************************************************************************************** + + - name: set_state_machine_input + type: function + desc: Set the input values from a state machine input, either from the current top-level artboard, or from a nested artboard inside the Rive model artboard. Note - To set input for a trigger, use a bool value. + + parameters: + - name: url + type: url + desc: The Rive model + + - name: name + type: string + desc: The name of the input + + - name: value + type: number|bool + desc: The value of the input to set + + - name: nested_artboard + type: string + desc: (OPTIONAL) If specified, the input will be queried for the specified nested artboard diff --git a/docs/index.md b/docs/index.md index 096cd27..cb5df09 100644 --- a/docs/index.md +++ b/docs/index.md @@ -240,6 +240,15 @@ local v = rive.get_state_machine_input("#rivemodel", "Number 1", "My_Nested_Artb -- To go deeper into the nested hierarchy, you can add slashes between each scope local v = rive.get_state_machine_input("#rivemodel", "Number 1", "My_Nested_Artboard/My_Inner_Nested_Artboard") + +-- Set the input value of the current state machine +rive.set_state_machine_input("#rivemodel", "Number 1", 0.5) + +-- Set the input value of a nested artboard +rive.set_state_machine_input("#rivemodel", "Number 1", 0.5, "My_Nested_Artboard") + +-- Same as the example above, to go even deeper, separate the scopers with slashes! +rive.set_state_machine_input("#rivemodel", "Number 1", 0.5, "My_Nested_Artboard/My_Inner_Nested_Artboard") ``` #### Events