22. Apply choices to visible game behavior
Here is a complete Apply script for two boxes and a sample subtitle Label. It works whether or not you added live variable bindings. Create the two Boolean variables before testing.
extends "res://scripts/runtime/script_base.gd"func run(_context: Dictionary = {}) -> Variant:
var subtitles: bool = bool(GetGUIElementProperty(
"settings_lab", "subtitles_check", "button_pressed", false
))
var hints: bool = bool(GetGUIElementProperty(
"settings_lab", "hints_check", "button_pressed", false
))
await SetVariable({
"name": "show_subtitles", "value": subtitles
})
await SetVariable({
"name": "show_hints", "value": hints
})
if subtitles:
await ShowGUIElement({
"guiId": "settings_lab",
"elementId": "sample_subtitle"
})
else:
await HideGUIElement({
"guiId": "settings_lab",
"elementId": "sample_subtitle"
})
return true1. Add a Label with ID sample_subtitle and some sample speech text.
2. Create this script record, Apply Changes and assign it to an Apply choices Button.
3. Run the game. Turn Show subtitles off and press Apply. The sample Label disappears.
4. Turn it on and apply again. The Label returns.
This demonstration controls one Label. A full game’s subtitle and hint systems must deliberately use the saved preferences; captions on check boxes do not connect those systems automatically.
