Wait for a Lua condition
wait_forWait for a Lua condition to become true in a chosen realm, polling each frame or at a set interval until it succeeds or times out. Returns status, elapsed time, polls, and last value.
Instructions
Waits until a Lua condition is true. condition is an expression ("IsValid(Entity(57))") or a block with return ("local d = Entity(57) return IsValid(d) and d:GetInternalVariable('m_eDoorState') == 2"), compiled once and evaluated in realm every frame (or every interval_s); true = anything but nil/false. Each evaluation may run 1 s at most. Result: {satisfied: true, elapsed_s, polls, value (the last value)}. Errors: timeout (details: polls, last_value), realm_lost (the realm was destroyed or recreated, e.g. a map change, during the wait), realm_unavailable, lua_syntax_error, lua_error. Reports progress; can run as an MCP task.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"condition": "<condition>"
},
"name": "wait_for"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| realm | No | Evaluation realm (default server). | |
| instance | No | Optional. Instance identifier (see instances_list). If present and different from the local instance, the call is relayed by the coordinator to that instance. | |
| condition | Yes | Lua expression or block with return, e.g. 'IsValid(Entity(1)) and Entity(1):Alive()'. | |
| timeout_s | No | Max wait in seconds (default 10). | |
| interval_s | No | Seconds between evaluations (default 0 = every frame). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| next | No | ||
| note | No | ||
| polls | Yes | ||
| value | No | ||
| warning | No | ||
| elapsed_s | Yes | ||
| next_call | No | ||
| satisfied | Yes | ||
| answered_by | No | ||
| truncated_note | No | ||
| version_warning | No |