Skip to reading
Images, Carousels & Choice Controls

19. Read or bind a Check Box

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView illustrations

For a separate Apply Button, read the live button_pressed property. The authored checked property describes construction data; it is not a dependable read of the player’s current choice.

Code example
var subtitles: bool = bool(GetGUIElementProperty(
    "settings_lab", "subtitles_check", "button_pressed", false
))
await SetVariable({
    "name": "show_subtitles", "value": subtitles
})

Put those lines inside a run function based on script_base.gd. If you prefer live variable updates whenever the box toggles, add a runtime binding instead.

1. Create a Boolean variable named show_subtitles with initial value true.

2. Select subtitles_check and open Raw JSON (Advanced). Keep the element’s existing properties.

3. Add the member below immediately after the opening brace, or edit the existing variable member.

4. Validate and Apply Element JSON, save, then test in gameplay.

Code example
"variable": "show_subtitles",

Figure 30. The Check Box’s checked and variable members are distinct. Keep the variable default and starting check mark consistent.

Give Show hints its own Boolean variable, show_hints. Two independent check boxes should not share one output variable unless your logic deliberately combines them.

Page 36 of 52Permalink
Go to page