--- title: AI orders and the ship queue summary: Priority, interruption, cancellation and verifying the real result of an AI script. section: scripting kind: guide status: observed tags: ["X4","modding","orders"] sources: ["https://wiki.egosoft.com/X4%20Foundations%20Wiki/Modding%20Support/"] --- ## The order and its running script Inspect the actual order handle and ship queue. A script end or interruption event does not always mean the order was removed. In X4 9.00 research, `event_object_order_cancelled` occurred when a priority order interrupted behavior, while the previous handle remained in the queue as ready. ## Verify cancellation Confirm that the correct ship exists, the intended order is cancelled and the handle is truly absent afterward. One event is insufficient. The opposite race is also possible: a handle may disappear before a delayed event. Define completion conditions for the specific operation. ## Priority and movement `immediate` and `priority` on `create_order` mean different things. Read the real queue order after changing priority; a local `$Priority` variable proves nothing about AI behavior. For movement, also check final coordinates. Script completion alone does not prove arrival. ## Regression Test a normal order, several queued actions, priority interruption, cancellation and save loading. Do not generalize one MoveWait result to every AI script. See [game effect verification](wiki:testing) and [MD persistence](wiki:md-persistence).