Skip to Content
defold-typescript libraries
defold (official)

defold/extension-onion-runtime/onion

Functions and constants for interacting with Onion APIs.

  • GitHub: defold/extension-onion-runtime — pinned to ad12c4b
    1. This repo publishes no releases or tags. Add a commit archive URL — for the pinned commit, https://github.com/defold/extension-onion-runtime/archive/ad12c4bba8dd286cb39be1151dfc5abcd8d87f70.zip — 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 onion from "onion"

Functions

onion.play_animation(url: string | hash | url, animation_id: string | hash, playback: number, options: table, callback_function: function)

Plays the specified animation on a Onion model.

Parameters

  • url: string | hash | url — The Onion model.
  • animation_id: string | hash — Id of the animation to play.
  • playback: number — Playback mode of the animation (available go.PLAYBACK_ONCE_FORWARD, go.PLAYBACK_LOOP_FORWARD).
  • options: table — Playback options.
    • offset: number — The normalized initial value of the animation cursor when the animation starts playing.
  • callback_function: function — function to call when the animation has completed or a Onion event occured.
    • self: object — The context of the calling script.
    • message_id: hash — The name of the message ("onion_animation_done" or "onion_event").
    • message: table — A table that contains the response.
      • animation_id: hash — The animation that was completed.
      • entity_id: hash — The entity that was completed.
      • event_id: hash — (onion_event only!) the event that was triggered.
      • time: float — (onion_event only!) the time at which the event occurred (seconds).
    • sender: url — The invoker of the callback - the Onion model component.

onion.set_entity(url: string | hash | url, entity: string | hash)

Sets the entity on a onion model.

Parameters

  • url: string | hash | url — The Onion model.
  • entity: string | hash — Id of the entity.

onion.set_symbol_group(url: string | hash | url, symbol_group_id: string | hash)

Sets the symbol group on a onion model.

Parameters

  • url: string | hash | url — The Onion model.
  • symbol_group_id: string | hash — Id of the symbol group.

onion.pause()

Sets the pause on a onion model.

onion.resume()

Sets the resume on a onion model.

onion.hide_layer(url: string | hash | url, layer_id: string | hash)

Sets hide layer on a onion model.

Parameters

  • url: string | hash | url — The Onion model.
  • layer_id: string | hash — Id of the layer.

onion.show_layer(url: string | hash | url, layer_id: string | hash)

Sets show layer on a onion model.

Parameters

  • url: string | hash | url — The Onion model.
  • layer_id: string | hash — Id of the layer.

onion.show_all_layers()

Sets show all layers on a onion model.

onion.hide_symbol(url: string | hash | url, symbol_id: string | hash)

Sets hide symbol on a onion model.

Parameters

  • url: string | hash | url — The Onion model.
  • symbol_id: string | hash — Id of the symbol.

onion.show_symbol(url: string | hash | url, symbol_id: string | hash)

Sets show symbol on a onion model.

Parameters

  • url: string | hash | url — The Onion model.
  • symbol_id: string | hash — Id of the symbol.

onion.show_all_symbols()

Sets show all symbols on a onion model.

onion.override_symbol(url: string | hash | url, symbol_id: string | hash, to_symbol_id: string | hash, from_symbol_group_id: string | hash)

Sets override symbol on a onion model.

Parameters

  • url: string | hash | url — The Onion model.
  • symbol_id: string | hash — Id of the symbol.
  • to_symbol_id: string | hash — Id of the symbol to replace.
  • from_symbol_group_id: string | hash — Id of the symbol group from replace.

onion.clear_override_symbol(url: string | hash | url, symbol_id: string | hash)

Sets clear override symbol on a onion model.

Parameters

  • url: string | hash | url — The Onion model.
  • symbol_id: string | hash — Id of the symbol.

onion.clear_all_override_symbols()

Sets clear all override symbol on a onion model.

onion.add_override_symbol_group(url: string | hash | url, symbol_group_id: string | hash)

Sets add override symbol group on a onion model.

Parameters

  • url: string | hash | url — The Onion model.
  • symbol_group_id: string | hash — Id of the symbol group.

onion.clear_override_symbol_group(url: string | hash | url, symbol_group_id: string | hash)

Sets clear override symbol group on a onion model.

Parameters

  • url: string | hash | url — The Onion model.
  • symbol_group_id: string | hash — Id of the symbol group.

onion.clear_all_override_symbol_groups(url: string | hash | url)

Sets clear all override symbol group on a onion model.

Parameters

  • url: string | hash | url — The Onion model.

onion.set_hflip(url: string | hash | url, flip: bool)

Sets flip horisontal on a onion model.

Parameters

  • url: string | hash | url — The Onion model.
  • flip: bool — Sign of flip.

onion.set_vflip(url: string | hash | url, flip: bool)

Sets flip vertical on a onion model.

Parameters

  • url: string | hash | url — The Onion model.
  • flip: bool — Sign of flip.

onion.set_blend_mode(url: string | hash | url, blend: integer)

Sets blend on a onion model.

Parameters

  • url: string | hash | url — The Onion model.
  • blend: integer — Id of the blend mode.

onion.get_blend_mode(url: string | hash | url): integer

Sets blend on a onion model.

Parameters

  • url: string | hash | url — The Onion model.

Returns

  • blend: integer — Id of the blend mode.

On this page