Skip to reading
Images, Carousels & Choice Controls

22. Apply choices to visible game behavior

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 PDF page

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.

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
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 true

1. 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.

Page 41 of 52Permalink
Go to page