Skip to reading
Images, Carousels & Choice Controls

Store a radio choice as a stable value

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

For simple story logic, store one String such as relaxed, standard or challenging after reading the completed group. Do not store a translated caption as the identity of a difficulty mode.

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_context: Dictionary = {}) -> Variant:
    var mode: String = "relaxed"
    if bool(GetGUIElementProperty(
        "settings_lab", "radio_standard", "button_pressed", false
    )):
        mode = "standard"
    elif bool(GetGUIElementProperty(
        "settings_lab", "radio_challenging", "button_pressed", false
    )):
        mode = "challenging"
    await SetVariable({
        "name": "difficulty_mode", "value": mode
    })
    return true

Create a String variable difficulty_mode with initial value relaxed. Run this script from Apply or Continue after the player has finished choosing.

Optional variable bindings on Radio Buttons write Booleans, just like a Check Box. If you use them, give each option its own Boolean, such as mode_relaxed, mode_standard and mode_challenging. Selecting a new option turns the previous one off.

Do not bind all three radio buttons to the same String variable. Their toggle notifications write true and false; they do not automatically write the radio button’s ID or caption.

Page 39 of 52Permalink
Go to page