News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

[Script API] Add convoy has_no_route() and is_stuck() predicates

Started by victor_18993, August 17, 2026, 06:17:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

victor_18993

Two new Script API methods for convoys have been added to trunk in r12171:

    convoy_x.has_no_route()
    convoy_x.is_stuck()

They expose conditions that Simutrans already tracks internally and already shows in the GUI, but that scenario and AI scripts could not query directly before.

`has_no_route()` returns true only when the convoy is in the engine's NO_ROUTE state.

`is_stuck()` uses the same definition as the GUI and convoy list filter: it returns true only for the two long-wait states that represent a convoy blocked for roughly two months.

This deliberately differs from `is_waiting()`:

- `is_waiting()` can be true for a normal temporary wait, such as waiting at a signal.
- `has_no_route()` identifies a convoy for which route calculation has failed.
- `is_stuck()` identifies a convoy that has remained blocked long enough for the game itself to classify it as stuck.

This allows scenario and AI authors to detect operational convoy problems directly instead of trying to infer them from waiting state, timers or other indirect information.

The implementation is read-only and uses the existing synchronized convoy state. There are no changes to simulation behaviour, savegames or the network protocol.

A permanent regression test also drives a real running convoy into NO_ROUTE by redirecting it to an unreachable road and verifies the new public API.

Integrated in:

    SVN r12171
    ADD: script API predicates for convoy no-route and stuck state

Full regression after integration:

    286 / 286 PASS

Related discussion / original request:
https://forum.simutrans.com/index.php?topic=13473.0
En la vida todo son vivencias y cada una de ellas nos hace mas grandes,¿Como de grande eres tu? :)