13. Check the room and puzzle state in a custom handler
Full phrases are not parameter patterns#
A custom row named give [item] is not a built-in wildcard that accepts any item. It is a phrase to compare. For object-based commands, use verbs, target synonyms and preposition interactions. For a more specialised grammar, read the original command in your own script and deliberately implement the extra rules you need.
Likewise, a whole-command handler is not automatically owned by the clock. Do not assume this means the noun the player typed. Use an explicit target ID or the context appropriate to the action that called the script.
The check clock example reports whether the clock has been wound. It also refuses the command outside the workshop. This makes a useful distinction: matching a phrase and allowing its effect are separate decisions.
Create a GDScript record called Check the Clock, with ID check_clock. Use the following source, substituting your actual scene ID for workshop if necessary.
extends "res://scripts/runtime/script_base.gd"func run(_command_context: Dictionary = {}) -> Variant:
if Runtime.scene_id != "workshop":
await ShowMessage({
"text": "Try that in the workshop.",
"duration": 7.0
})
return false var reply: String = "The clock is still silent."
if IfVariable("clock_wound", true):
reply = "The clock is ticking again."
await ShowMessage({"text": reply, "duration": 7.0})
return trueValidate, apply and save the script. In Text Parser, add check clock and choose Check the Clock(check_clock). Apply and save those settings too.
