Skip to Content
defold-typescript libraries
defold (official)extension-rive

defold/extension-rive/rive

Rive animation helpers exposed to Lua scripts

  • GitHub: defold/extension-rive — pinned to 13.1.0 (released while Defold 1.13.1 was current)
    1. Pick a release from defold/extension-rive releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as rive from "rive"

Functions

rive.pointer_move(url: url, x: number, y: number, pointer_id: number | nil)

Lua wrapper for pointer movement.

Parameters

  • url: url — Component receiving the pointer move.
  • x: number — Pointer x coordinate in component space.
  • y: number — Pointer y coordinate in component space.
  • pointer_id: number | nil — Optional stable pointer identifier for multitouch. Defaults to 0.

rive.pointer_up(url: url, x: number, y: number, pointer_id: number | nil)

Lua wrapper for pointer up events.

Parameters

  • url: url — Component receiving the pointer release.
  • x: number — Pointer x coordinate.
  • y: number — Pointer y coordinate.
  • pointer_id: number | nil — Optional stable pointer identifier for multitouch. Defaults to 0.

rive.pointer_down(url: url, x: number, y: number, pointer_id: number | nil)

Lua wrapper for pointer down events.

Parameters

  • url: url — Component receiving the pointer press.
  • x: number — Pointer x coordinate.
  • y: number — Pointer y coordinate.
  • pointer_id: number | nil — Optional stable pointer identifier for multitouch. Defaults to 0.

rive.pointer_exit(url: url, x: number, y: number, pointer_id: number | nil)

Lua wrapper for pointer exit events.

Parameters

  • url: url — Component receiving the pointer leave.
  • x: number — Pointer x coordinate.
  • y: number — Pointer y coordinate.
  • pointer_id: number | nil — Optional stable pointer identifier for multitouch. Defaults to 0.

rive.get_projection_matrix(): vmath.matrix4

Returns the projection matrix in render coordinates.

Returns

  • matrix: vmath.matrix4 — Current projection matrix for the window.

rive.set_file_listener(callback: function(self, event, data) | nil)

Sets or clears the global file listener callback.

Parameters

  • callback: function(self, event, data) | nil — Callback invoked for file system events; pass nil to disable.
    • self: object — The calling script instance.
    • event: string — One of onFileLoaded, onFileDeleted, onFileError, onArtboardInstantiated, onArtboardsListed, onViewModelsListed, onViewModelInstanceInstantiated, onViewModelInstanceNamesListed, onViewModelPropertiesListed, onViewModelEnumsListed
    • data: table — Additional fields vary by event. Common keys include
      • file: FileHandle — File handle involved in the event.
      • artboard: ArtboardHandle — Instantiated artboard handle, when applicable.
      • viewModel: ViewModelInstanceHandle — Instantiated view model instance handle, when applicable.
      • viewModelName: string — View model name for the request, when applicable.
      • instanceNames: table — Array of instance name strings.
      • artboardNames: table — Array of artboard name strings.
      • properties: table — Array of property metadata tables.
      • enums: table — Array of enum definitions.
      • error: string — Error message when a failure occurs.

rive.get_file(url: url): FileHandle

Returns the Rive file handle tied to the component.

Parameters

  • url: url — Component whose file handle to query.

Returns

  • file_handle: FileHandle — Handle identifying the loaded Rive file.

rive.set_artboard(url: url, name: string | nil): ArtboardHandle

Switches the active artboard for the component.

Parameters

  • url: url — Component using the artboard.
  • name: string | nil — Name of the artboard to create and set. Pass nil to create a default artboard.

Returns

  • artboard: ArtboardHandle — Old artboard handle

rive.get_artboard(url: url): ArtboardHandle

Queries the current artboard handle for the component.

Parameters

  • url: url — Component whose artboard handle to return.

Returns

  • artboard: ArtboardHandle — Active artboard handle.

rive.set_state_machine(url: url, name: string | nil): StateMachineHandle

Selects a state machine by name on the component.

Parameters

  • url: url — Component owning the state machine.
  • name: string | nil — Name of the state machine to create and set. Pass nil to create a default state machine.

Returns

  • state_machine: StateMachineHandle — Old state machine handle

rive.get_state_machine(url: url): StateMachineHandle

Returns the active state machine handle for the component.

Parameters

  • url: url — Component whose active state machine to query.

Returns

  • state_machine: StateMachineHandle — Current state machine handle.

rive.set_view_model_instance(url: url, name: string): ViewModelInstanceHandle

Selects a default view model instance by name.

Parameters

  • url: url — Component owning the view model instance.
  • name: string — View model name whose default instance should be activated.

Returns

  • view_model_instance_handle: ViewModelInstanceHandle — Handle to the old view model instance.

rive.get_view_model_instance(url: url): ViewModelInstanceHandle

Returns the handle of the currently bound view model instance.

Parameters

  • url: url — Component whose view model instance handle to query.

Returns

  • view_model_instance_handle: ViewModelInstanceHandle — Handle for the active view model instance.

On this page