Station construction sequence
How does a station go from βlist of planned modulesβ to βphysical modules visible in spaceβ? Every multi-module station build β initial seeding, NPC expansion, player plot construction β runs through the construction sequence pipeline. This overview explains the four-step engine β MD dance.
This overview is the runtime mechanic counterpart to Galaxy seeding (which only covers the initial spawn). Construction sequence runs both at game start AND during gameplay.
The pipeline
Section titled βThe pipelineββββββββββββββββββββββββββββββββββββββββββββββββββββ Caller (MD script) ββ <create_construction_sequence ...> ββ station=$Station ββ macros=[$mod1, $mod2, ...] ββ base=$existing_sequence (or empty) ββ </create_construction_sequence> βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββββββββ Engine ββ - validates macros + connections ββ - computes geometry / build order ββ - emits event_object_construction_sequence_ ββ created with event.param = sequence βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββββββββ Listener cue ββ <event_object_construction_sequence_created/> ββ <apply_construction_sequence ββ station=$Station ββ sequence=event.param/> βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββββββββ Engine ββ - materializes modules ββ - sets up build modules / processors ββ - fires <signal_objects 'init station'> ββ on the new station βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββββββββ Station operational βββββββββββββββββββββββββββββββββββββββββββββββββββStep 1: create_construction_sequence
Section titled βStep 1: create_construction_sequenceβThe caller (typically a faction-logic or finalisation cue) requests a sequence:
<create_construction_sequence station="$Station" macros="$NewPlannedModules" connectors="$Conn_PlannedConnectors" base="$BaseSequence"/>Parameters:
| Param | Purpose |
|---|---|
station= | The target station object |
macros= | List of module macros to include |
connectors= | Connection modules between them |
base= | Existing sequence to extend (null for fresh start) |
The engine takes these as a request β it doesnβt immediately build anything. It validates, computes, and fires the next-step event.
Step 2: event_object_construction_sequence_created
Section titled βStep 2: event_object_construction_sequence_createdβThe engine emits this event once the sequence is ready. Vanilla cues listen for it to know βthe sequence I requested is ready to applyβ:
<cue name="ApplyAfterCreate" instantiate="true"> <conditions> <event_object_construction_sequence_created object="$Station"/> </conditions> <actions> <apply_construction_sequence station="$Station" sequence="event.param"/> </actions></cue>Pattern from vanilla finalisestations.xml (multiple cues use this).
The event.param holds the constructed sequence β a Construction sequence datatype value. The listener immediately calls <apply_construction_sequence> to materialize.
Step 3: apply_construction_sequence
Section titled βStep 3: apply_construction_sequenceβ<apply_construction_sequence station="$Station" sequence="event.param"/>The engine now physically builds the modules. This involves:
- Module placement β each module rendered at its computed position
- Connection wiring β connectors linked between adjacent modules
- Build module activation β if this is a player station, build modules get cargo storage
- Initial state setup β production paused, defence modules unarmed, etc.
The sequenceβs modules become visible in the world.
Step 4: signal_objects βinit stationβ
Section titled βStep 4: signal_objects βinit stationββAfter all modules exist, the engine fires a signal_objects on the station with the parameter 'init station'. This is the canonical βstation is now fully operationalβ signal:
<signal_objects object="$Station" param="'init station'"/>Listeners for event_object_signalled with param="'init station'" can react β vanilla uses this for:
- Trade subscription registration
- Faction logic notification
- NPC patrol assignment
After this signal, the station appears in find_station_by_true_owner queries, accepts trade orders, can be boarded, etc.
X4 9.0+: staged construction
Section titled βX4 9.0+: staged constructionβX4 9.0 added staged construction β player can specify βbuild these first, those laterβ. The sequence tracks the current stage:
sequenceβββ stage 1: pier + dock area + storage β currentβββ stage 2: production module 1βββ stage 3: production module 2Sequence.stage.current indicates the current stage. The engine builds modules in the current stage, then waits for player approval before advancing.
9.0 caller distinction
Section titled β9.0 caller distinctionβ<create_construction_sequence> errors on stations with staged construction. For staged stations, use <add_build_to_expand_station> instead:
<do_if value="not $Station.hasstagedconstruction"> <create_construction_sequence ...></do_if><do_else> <add_build_to_expand_station object="$Station.buildstorage" buildobject="$Station" constructionplan="$Plan" result="$BuildID"/></do_else>Pattern from factionsubgoal_buildstation.xml:211 + finalisestations.xml:359. See Build module β Stage-aware build appending.
Use cases
Section titled βUse casesβInitial galaxy seeding
Section titled βInitial galaxy seedingβGalaxy seeding is the primary user. Every NPC station at game start runs through this pipeline.
NPC faction expansion
Section titled βNPC faction expansionβWhen factionlogic_economy decides to build a new factory:
<create_construction_sequence>with the new factoryβs modules- Listener catches the event
<apply_construction_sequence>materializessignal_objects 'init station'registers it with trade
Player station construction
Section titled βPlayer station constructionβPlayer Plot UI adds modules β MD <add_build_to_expand_station> (X4 9.0+) β engine emits sequence events β engine materializes.
Cross-references
Section titled βCross-referencesβ- Build module β what executes the sequence
- Construction sequence (data) β the data structure
- Station β what gets built
- constructionplans.xml β the source of plans
- stationgroups.xml β module composition templates
Related architectural overviews
Section titled βRelated architectural overviewsβ- Galaxy seeding β initial spawn (parent context)
- Faction economy β drives runtime construction requests
- Plot expansion UX β player-side construction flow