Delegate Reference

Delegates

Delegates are tables which contain the setup properties for Dialogs; they are essentially templates that determine a Dialog's appearance and behavior based on a set of values, scripts, and widgets.

Values


cancels_on_spawn

When the Dialog is spawned, it will cancel all other Dialogs named in the list. (table)

Example

	LibDialog:Register("KillMyOtherDialogsExample", {
		cancels_on_spawn = {
			"MyAwesomeDialog",
			"MyNotSoGreatDialog",
		},
		hide_on_escape = true,
	})

duration

Number of seconds the Dialog will exist before automatically being dismissed. (number)

height

Height for the Dialog (in pixels); if omitted or 0, causes the Dialog's height to be determined automatically based on its contents. (number)

hide_on_escape

Causes the Dialog to be dismissed when the Escape key is pressed. (boolean)

icon

Assigns an icon to the Dialog found at the given file path. (string)

icon_size

Sets the width and height of the Dialog's icon (in pixels). Defaults to 36. (number)

is_exclusive

Description. (boolean)

no_cancel_on_escape

Do not cancel this Dialog when the Escape key is pressed. (boolean)

no_cancel_on_reuse

Do not cancel pre-existing Dialogs of this designation when a new instance is created. (boolean)

show_during_cinematic

Do not cancel this Dialog when a Cinematic cut-scene begins. (boolean)

show_while_dead

Allow the Dialog to be shown while the character is dead. (boolean)

sound

Plays an audio file at the given path when the Dialog is shown. (string)

static_size

Sets the Dialog's width to the specified size. Ignores contained widgets for resizing purposes. (number)

text

The text displayed on the Dialog, before its widgets. (string)

text_justify_h

Sets the Dialog's horizontal text alignment style based on the following values: (string)

  • CENTER
  • LEFT
  • RIGHT

text_justify_v

Sets the Dialog's vertical text alignment style based on the following values: (string)

  • BOTTOM
  • MIDDLE
  • TOP

width

Width for the Dialog (in pixels); if omitted or 0, causes the Dialog's height to be determined automatically based on its contents. (number)

Scripts


on_cancel = function(self, data, reason)

Called when the Dialog is canceled.

Arguments

  • self - Reference to the Dialog for which the script was run. (frame)

  • data - The data passed to the Delegate when the Dialog was instantiated via lib:Spawn() (variable)

  • reason - Reason for cancelation. Not always present. The library will use the following according to circumstance: (string)

    • timeout - Passed when a Dialog's duration has run out.
    • override - Passed when a Dialog is dismissed by either being in the cancels_on_spawn list of another Dialog, having its is_exclusive value set to true when another Dialog with its is_exclusive value set is spawned, or when the same Dialog is spawned again and its no_cancel_on_reuse value is empty or false.

on_hide = function(self)

Run when the Dialog becomes invisible.

Arguments

  • self - Reference to the Dialog for which the script was run. (frame)

on_show = function(self)

Run when the Dialog becomes visible.

Arguments

  • self - Reference to the Dialog for which the script was run. (frame)

on_update = function(self, elapsed)

Run each time the screen is drawn by the game engine. This handler runs for each frame draw.

Arguments

  • self - Reference to the Dialog for which the script was run. (frame)

  • elapsed - Number of seconds since the OnUpdate handlers were last run (likely a fraction of a second). (number)