Skip to main content

Singable

Overview

The Singable component allows an entity to be sung by a player. It stores an optional callback function (onsingfn) that is invoked upon singing and ensures the singer's singinginspiration component records the song via AddSong, using the entity's songdata property.

Dependencies & Tags

  • Requires inst.songdata to be defined on the entity (typically a table of song parameters).
  • Assumes the singer entity has a singinginspiration component.
  • Does not add or remove tags; comments suggest potential future interaction with finiteuses, but this is currently commented out.

Properties

PropertyTypeDefault ValueDescription
instEntityReference to the entity this component is attached to.
onsingfnfunction?nilOptional callback function executed during singing; signature: fn(entity, singer).

Main Functions

SetOnSing(onsingfn)

  • Description: Assigns a callback function to be executed when the entity is sung. The callback receives the songable entity and the singer as arguments.
  • Parameters:
    • onsingfn (function?) — A function to call when singing occurs. If nil, no callback is executed.

Sing(singer)

  • Description: Triggers the singing logic: validates the singer has a singinginspiration component, executes the callback if set, and registers the song with the singer's inspiration component.
  • Parameters:
    • singer (Entity) — The player entity attempting to sing this item.

Events & Listeners

None.