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

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


Functions

tk.choice (title, msg, ..., choices)
Creates a window with a number of selectable options

Parameters

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

Usage:

num, chosen = tk.choice( "Title", "Ready to go?", "Yes", "No" ) -- If "No" was clicked it would return 2, "No"

Return value:

Returns the number of the choice and the name of the choice chosen.
tk.input (title, min, max, str)
Creates a window that allows player to write text input.

Parameters

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

Usage:

name = tk.input( "Name", 3, 20, "Enter your name:" )

Return value:

nil if input was canceled or a string with the text written.
tk.list (title, msg, ..., choices)
Creates a window with an embedded list of choices.

Parameters

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

Usage:

num, chosen = tk.list( "Title", "Foo or bar?", "Foo", "Bar" ) -- If "Bar" is clicked, it would return 2, "Bar"

Return value:

Returns the number of the choice and the name of the choice chosen.
tk.msg (title, message, image, width, height)
Creates a window with an ok button, text and an image.

Parameters

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

Usage:

tk.msg( "Title", "This is a message.", "character.png" )
tk.msg (title, message, image, width, height)
Creates a window with an ok button, text and an image.

Parameters

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

Usage:

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

Parameters

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

Usage:

if tk.yesno( "YesNo popup box", "Click yes to do something." ) then -- Clicked yes

Return value:

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

Valid XHTML 1.0!