Module RunnerForm

A form used by a Game Runner program to configure parameters. It can be used to specify input fields, prompt the user with a form to input values for those fields, and fetch the values input by the user after the form is submitted.

For example:

form:addStageSelect("Stage")
form:default("Stage", "sample/battle1.lua")
form:addMultiShipSelect("Reference Ships")
form:default("Reference Ships", {"sample/randombot.lua", "sample/chaser.lua"})
form:addIntegerText("Seasons")
form:default("Seasons", 10)
if (form:ok()) then
    local seasons = form:get("Seasons")
...

Functions

addCheckbox (name) Adds a checkbox to the form.
addDropdown (name, options) Adds a dropdown to the form.
addIntegerText (name) Adds a text control to the form.
addMultiShipSelect (name) Adds a multi-ship select control to the form.
addSingleShipSelect (name) Adds a ship select control to the form.
addStageSelect (name) Adds a stage select control to the form.
default (name, values) Specifies the default value(s) for a form field.
get (name) Retrieves the value(s) of a form field.
ok (message) Prompts the user for input based on the fields configured in this object.
reset () Removes all fields and values from the form.


Functions

addCheckbox (name)

Adds a checkbox to the form. It produces a boolean value.

Parameters

  • name: The name of the field. This is displayed on the form and used to fetch the result after the form is submitted.
addDropdown (name, options)

Adds a dropdown to the form. It produces a string value.

Parameters

  • name: The name of the field. This is displayed on the form and used to fetch the result after the form is submitted.
  • options: A table of values to be listed as options in the dropdown.
addIntegerText (name)

Adds a text control to the form. It produces an integer value.

Parameters

  • name: The name of the field. This is displayed on the form and used to fetch the result after the form is submitted.
addMultiShipSelect (name)

Adds a multi-ship select control to the form. This is used to specify any number of ships, similar to when selecting ships for a new match. It produces a table of strings.

Parameters

  • name: The name of the field. This is displayed on the form and used to fetch the result after the form is submitted.
addSingleShipSelect (name)

Adds a ship select control to the form. This is used to specify a single ship, similar to when selecting ships for a new match. It produces a string value.

Parameters

  • name: The name of the field. This is displayed on the form and used to fetch the result after the form is submitted.
addStageSelect (name)

Adds a stage select control to the form. This is used to specify a single stage, similar to when selecting a stage for a new match. It produces a string value.

Parameters

  • name: The name of the field. This is displayed on the form and used to fetch the result after the form is submitted.
default (name, values)

Specifies the default value(s) for a form field.

Parameters

  • name: The name of the field.
  • values: A value or a table of values to be the initial values of the form control with the specified name.
get (name)

Retrieves the value(s) of a form field.

Parameters

  • name: The name of the field.

Return value:

A value or table of values for the field with the specified name.
ok (message)

Prompts the user for input based on the fields configured in this object.

This can be called multiple times. After the first call, subsequent calls retain the previously input values as defaults. This allows the Game Runner program to do validation on input and display the form again with a message specifying the problem with the input values.

Parameters

  • message: (optional) A message to be displayed on the form.

Return value:

true if the user completed the form and hit OK, false if the user canceled the operation.
reset ()

Removes all fields and values from the form.