Dialog:getValueById()
Returns the answer to the question with this id.
Signature
Dialog:getValueById(id: number): any
Returns
| Question | Returns |
|---|---|
CheckBox | boolean |
EditText | string |
NumberInput | number, or nil when it is optional and empty |
Slider | number |
RadioGroup, also as a dropdown | number: the id of the chosen RadioButton |
TapPicker | Point, or nil when it is optional and not picked |
TapListPicker | a list of Points, empty when nothing is picked |
GestureRecorder | string: 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()orDialog: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
showWhenstill returns its last answer.