Skip to reading
Images, Carousels & Choice Controls

14. Read the current carousel entry

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

The current carousel entry is not automatically written to a Selected Item Variable. This build does not expose a typed output field like the List Box does. A separate confirmation Button can read it through the public GUI-property helpers.

Create a String variable gallery_feedback and a Label with Text $$gallery_feedback. Then create this GDScript record:

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_context: Dictionary = {}) -> Variant:
    var entries: Array = GetGUIElementProperty(
        "gallery_lab", "reference_carousel", "entries", []
    )
    var index: int = int(GetGUIElementProperty(
        "gallery_lab", "reference_carousel", "selected_index", 0
    ))
    var result: String = "The gallery is empty."
    if index >= 0 and index < entries.size():
        var entry: Dictionary = entries[index]
        result = str(entry.get("caption", ""))
        result += " | ID: " + str(entry.get("id", ""))
    await SetVariable({
        "name": "gallery_feedback", "value": result
    })
    return true

1. Apply Changes to the script.

2. Add a Read current entry Button. Set Click to run-visual-script and Click Target to the script ID.

3. Run the game, browse to Map Room and press the Button. Check the returned caption and ID.

entries and selected_index are widget properties checked in 0.86.3.4. This is an advanced property-reading workflow, rather than a dedicated carousel selection event.

Page 26 of 52Permalink
Go to page