Restore a radio group and reset defaults
For a saved difficulty String, restore the group by clearing its choices and checking the intended one. Use a known set of mode IDs rather than accepting any text as an element ID.
var mode: String = str(
Runtime.variables.get("difficulty_mode", "relaxed")
)
if mode not in ["relaxed", "standard", "challenging"]:
mode = "relaxed"
for option: String in ["relaxed", "standard", "challenging"]:
await ChangeGUIElementProperty({
"guiId": "settings_lab",
"elementId": "radio_" + option,
"property": "checked",
"value": false
})
await ChangeGUIElementProperty({
"guiId": "settings_lab",
"elementId": "radio_" + mode,
"property": "checked",
"value": true
})These lines belong inside a run function using script_base.gd. Put them after your Check Box and Slider restoration if one script restores the whole screen.
1. Choose Standard and a low opacity in gameplay, then apply them.
2. Change the saved variables deliberately. Observe that Set Variable alone does not redraw the existing choice controls.
3. Run the restore script. Check the visible controls now agree with the stored data.
4. For a Reset Defaults Button, set the variables to the chosen defaults first, restore the controls, then reapply their display effects.
Hiding and reopening a GUI is not a universal reset. Existing widget instances can retain state. A new game run starts again from authored settings and startup logic.
