22. Use the same operations in scripts
extends "res://scripts/runtime/script_base.gd"func run(_context: Dictionary = {}) -> Variant:
var slot_number: int = int(GetGUIElementProperty(
"save_lab", "save_slots", "selected_slot", -1))
if slot_number < 1:
await SetVariable({
"name": "save_feedback",
"value": "Choose a manual slot first."
})
return false
await SaveGameWidgetCommand({
"guiId": "save_lab",
"elementId": "save_slots",
"command": "save-selected",
"slot": -1
})
return trueThis Button script adds a guard before dispatching the normal widget command. With dedicated autosave 0, a manual choice must be at least 1. The widget still owns naming, overwrite confirmation and its mode/range rules.
The final true means the script dispatched the command. It does not mean the player finished the name dialog or accepted an overwrite. Do not award an achievement simply because this record returned true.
If you reserve a positive slot for autosave, adjust the guard to exclude that number too. The simple less-than-1 check only matches this workshop’s slot policy.
