Skip to main content

Dialog:getValueById()

Returns the answer to the question with this id.

Signature​

Dialog:getValueById(id: number): any

Returns

QuestionReturns
CheckBoxboolean
EditTextstring
NumberInputnumber, or nil when it is optional and empty
Slidernumber
RadioGroup, also as a dropdownnumber: the id of the chosen RadioButton
TapPickerPoint, or nil when it is optional and not picked
TapListPickera list of Points, empty when nothing is picked
GestureRecorderstring: a record name for Record:play(), or nil

Example​

Dialog:init()
Dialog:add(CheckBox(1, "Collect daily rewards", true))
Dialog:add(NumberInput(2, "Runs", 10))
Dialog:show()

local collect = Dialog:getValueById(1)
local runs = Dialog:getValueById(2)

Notes​

  • Read answers after Dialog:show() or Dialog:showIfNeeded(). Before that, you get the saved answer or the default.
  • The question must be in the current dialog. After a new Dialog:init(), the questions of the earlier dialog are gone; keep their answers in variables first.
  • A question hidden by showWhen still returns its last answer.