Home

Module tk

Bindings for interacting with the Toolkit.

These toolkit bindings are all blocking, meaning that your Lua code won't continue executing until the user closes the dialogue that popped up.

A typical example would be:

  tk.msg( "Title", "This is a message." )
  if tk.yesno( "YesNo popup box", "Click yes to do something." ) then
    -- Player clicked yes, do something
  else
    -- Player clicked no
  end
 

Functions

msg (title, message[, image=-1[, width=-1[, height=-1]]]) Creates a window with an ok button, and optionally an image.
yesno (title, message) Displays a window with Yes and No buttons.
input (title, min, max, str) Creates a window that allows player to write text input.
choice (title, msg, choices) Creates a window with a number of selectable options
list (title, msg, choices) Creates a window with an embedded list of choices.


Functions

msg (title, message[, image=-1[, width=-1[, height=-1]]])
Creates a window with an ok button, and optionally an image. ( title, message )

Parameters:

  • title string Title of the window.
  • message string Message to display in the window.
  • image string Image file (*.png) to display in the window. (default -1)
  • width number width of the image to display. Negative values use image width. (default -1)
  • height number height of the image to display. Negative values use image height. (default -1)

Usage:

  • tk.msg( "Title", "This is a message." )
  • tk.msg( "Title", "This is a message.", "character.png" )
yesno (title, message)
Displays a window with Yes and No buttons. ( title, message )

Parameters:

  • title string Title of the window.
  • message string Message to display in the window.

Returns:

    boolean true if yes was clicked, false if no was clicked.

Usage:

    if tk.yesno( "YesNo popup box", "Click yes to do something." ) then -- Clicked yes
input (title, min, max, str)
Creates a window that allows player to write text input. ( title, min, max, str )

Parameters:

  • title string Title of the window.
  • min number Minimum characters to accept (must be greater than 0).
  • max number Maximum characters to accept.
  • str string Text to display in the window.

Returns:

    string or nil nil if input was canceled or a string with the text written.

Usage:

    name = tk.input( "Name", 3, 20, "Enter your name:" )
choice (title, msg, choices)
Creates a window with a number of selectable options ( title, msg, ... )

Parameters:

  • title string Title of the window.
  • msg string Message to display.
  • choices string Option choices.

Returns:

  1. number The number of the choice chosen.
  2. string The name of the choice chosen.

Usage:

    num, chosen = tk.choice( "Title", "Ready to go?", "Yes", "No" ) -- If "No" was clicked it would return 2, "No"
list (title, msg, choices)
Creates a window with an embedded list of choices. ( title, msg, ... )

Parameters:

  • title string Title of the window.
  • msg string Message to display.
  • choices string Option choices.

Returns:

  1. number The number of the choice chosen.
  2. string The name of the choice chosen.

Usage:

    num, chosen = tk.list( "Title", "Foo or bar?", "Foo", "Bar" ) -- If "Bar" is clicked, it would return 2, "Bar"
generated by LDoc 1.4.3 Last updated 2020-03-30 00:45:13