Skip to reading
Eight Adventure Interface Workshops

Require a selected slot before saving

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

Record ID: strict_save. Global Script: off. This example is wired for mi_save / mi_saves. Replace those two IDs for another single-widget menu.

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_context: Dictionary = {}) -> Variant:
    var gui_id: String = "mi_save"
    var widget_id: String = "mi_saves"
    var slot: int = int(GetGUIElementProperty(
        gui_id, widget_id, "selected_slot", -1))
    if slot < 1:
        return false
    await SaveGameWidgetCommand({"guiId":gui_id,
        "elementId":widget_id, "command":"save-slot", "slot":slot})
    return true

The ordinary selected-slot command can fall back to the first available slot if no explicit row was selected. This guard returns without saving instead. Create a load variant by changing save-slot to load-slot.

1. Put the wrapper on the Save Button instead of a direct save-selected action.

2. Run the menu without choosing a row. Nothing should be saved.

3. Select a row, run Save, name the position and confirm the result.

4. Keep Prompt for Name and Confirm Overwrite enabled on the widget.

For an even clearer interface, disable Save/Load until a valid row is selected and provide a short instruction. A silent guard is a safety net, not the whole user experience.

Page 110 of 119Permalink
Go to page