Skip to reading
Eight Adventure Interface Workshops

Run Use from an object’s right-click event

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: right_use. Global Script: off. Attach this to the ordinary scene object’s On Right Click pointer event in the Direct-mode recipe.

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(event_context: Dictionary = {}) -> Variant:
    var target: String = str(event_context.get("entityId", ""))
    if target.is_empty():
        return false
    Runtime.call("set_verb", "use")
    await Runtime.call("execute_selected_verb", target)
    return true

1. Enable the object’s hotspot and define its Use verb result.

2. Add a Run Script action to its On Right Click event, selecting right_use.

3. Test without an item, then with a selected matching item.

4. Keep the script out of the Use result itself, or it would call the same interaction recursively.

The script expects entityId from a world-object event. It is intentionally not a general “use whatever is under the current pointer” function.

Page 99 of 119Permalink
Go to page