class_name ScriptRule extends RefCounted ## One parsed, validated rule: WHEN [trigger] IF [conditions] THEN [actions]. ## ## Rules are parsed once, by [ScriptBehavior], from a plain [Dictionary] that ## ultimately comes from untrusted UGC data (a JSON file on disk, or a dict ## embedded in a [WorldObject]'s `properties`). Every field on this class is ## a plain scalar (String/int/float/bool) or a small [Dictionary]/[Array] of ## scalars -- never a [Callable], a [Script], a [Node] reference, or anything ## else the data could use to reach into the engine. [ScriptInterpreterNode] ## is the only code that reads these fields, and it does so through an ## explicit `match` over a fixed whitelist -- see script_interpreter.gd. ## ## See docs/architecture/scripting_sandbox.md for why the data format has to ## look like this (no eval, no Expression, no call-by-name). ## One of "on_interact", "on_enter", "on_touch", "on_timer". var trigger_type: String = "" ## Only meaningful when trigger_type == "on_timer": seconds between firings. var trigger_interval: float = 0.0 ## Normalized condition dicts. Each has a "type" (one of ## ScriptBehavior.VALID_CONDITION_TYPES), an "op" (one of ## ScriptBehavior.VALID_OPS) and scalar operands -- see script_behavior.gd ## for the exact per-type shape. var conditions: Array[Dictionary] = [] ## Normalized action dicts. Each has a "verb" (one of ## ScriptBehavior.VALID_VERBS) and scalar arguments -- see ## script_behavior.gd for the exact per-verb shape. var actions: Array[Dictionary] = []