Expressions and Conditions
An expression computes a value from literals and data available in the current scope. A condition evaluates a comparison or other test to decide whether Logic should continue or choose a branch.
Start with Explicit Inputs
Declare a Number Parameter named speed, then use speed in a compatible Action field. A calculation such as speed * 2 makes the dependency clear and lets different attachments supply different speeds.
Use $score for a declared Project Global. Use self.health.current for the current field on the Object’s named health Data Structure slot. A private Local Variable is available only inside its own Logic scope.
Typed completion depends on the field, declared Parameters, Object contracts, Event context, and earlier Action results. If a value is missing from completion, check those declarations before writing an assumed name.
Build a Condition
Choose the value, an operator supported by its type, and the comparison value. For example, compare a Number health field with zero when deciding whether to destroy an instance.
Use the editor’s condition controls to express the test. Check that both sides are compatible and that the chosen Event actually provides every referenced Object or context field.
Text Containing Values
Text fields that support interpolation can insert expressions inside {...}. A global reference inside an interpolation still uses $name. The Action reference identifies which fields accept plain text, expressions, or interpolated text.
Test with zero, false, and empty text as well as typical values. These can be valid inputs and should not automatically mean “missing.”
For a failing expression, isolate it in a small Event Logic and use the Debugger to inspect the relevant state.
Verify a Numeric Expression
Use an existing compatible Logic attachment with a declared Number Parameter named speed.
- Bind
speedto3on the Object’s attachment. - In an Action’s compatible Number field, choose its expression input and enter
speed * 2. Select declared names through typed completion. - In a controlled check with Set Velocity, use this expression for X Velocity and
0for Y Velocity, with Applies To set to SELF. - Connect the sequence to the Event and End, then start a fresh run.
Expected result: the requested X velocity is 6 metres per second. Binding speed to 0 requests zero; no fallback should substitute a nonzero value merely because the input is zero. Physics and other velocity-writing Logic can subsequently change the observed motion.
Diagnose a Name or Type Error
| Symptom | Check and correction |
|---|---|
speed is unavailable |
Declare it in this Logic and bind it on this attachment; a similarly named declaration in another Logic is outside the scope. |
$score is unknown |
Declare the Project Global and check its exact identifier and type. |
self.health.current is invalid |
Confirm the health Data Structure slot, the current field, and the Object contract. |
| An Event field is unavailable | Select an Event that supplies the field and use completion in that Event’s Action context. |
| A result name is unavailable | Execute the producer before its consumer in the applicable sequence and name its result. |
| Text prints braces literally or does not evaluate | Confirm that the receiving field supports interpolation and that the expression inside the braces is valid. |
Resource names containing spaces are selected through their typed resource controls. Do not assume that a displayed resource name is a valid bare expression identifier. Keep Number calculations, Boolean conditions, and interpolated Text in fields that accept those respective types.
Myth Engine Documentation
