User Tools

Site Tools


manual:subwaysim:map_construction:create_maplua

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
manual:subwaysim:map_construction:create_maplua [2026/01/14 14:08] – [7.2.4 Pattern A — Simple Turnaround] dcsmanual:subwaysim:map_construction:create_maplua [2026/01/14 14:37] (current) – [Final Step – Build & Test the Map] dcs
Line 815: Line 815:
 Dispatching is handled by the **ControlCenter** and works in addition to normal timetables. Dispatching is handled by the **ControlCenter** and works in addition to normal timetables.
  
-===== 7.2.1 Basic Structure =====+==== 7.2.1 Basic Structure ====
  
 Dispatching strategies are defined as a table, grouped by station: Dispatching strategies are defined as a table, grouped by station:
Line 844: Line 844:
  
  
-===== 7.2.3 Strategy Fields =====+==== 7.2.3 Strategy Fields ====
  
 Each dispatching strategy can define the following fields: Each dispatching strategy can define the following fields:
Line 891: Line 891:
  
  
-===== 7.2.5 Pattern B — Turnaround with Internal Movement =====+==== 7.2.5 Pattern B — Turnaround with Internal Movement ====
  
 Some stations require a **shunting move** to turn a train. Some stations require a **shunting move** to turn a train.
Line 925: Line 925:
  
  
-===== 7.2.6 Pattern C — Spawning Trains from a Depot =====+==== 7.2.6 Pattern C — Spawning Trains from a Depot ====
  
 When no train is available, dispatching can **fetch a train from a depot**. When no train is available, dispatching can **fetch a train from a depot**.
Line 960: Line 960:
  
  
-===== 7.2.7 Pattern D — Sending Trains to a Depot =====+==== 7.2.7 Pattern D — Sending Trains to a Depot ====
  
 After service ends, trains can be removed from traffic. After service ends, trains can be removed from traffic.
Line 994: Line 994:
  
  
-===== 7.2.8 Hidden Timetables =====+==== 7.2.8 Hidden Timetables ====
  
 Timetables inside dispatching strategies: Timetables inside dispatching strategies:
Line 1009: Line 1009:
  
  
-===== 7.2.9 Strategy Order =====+==== 7.2.9 Strategy Order ====
  
 Dispatching strategies are evaluated **in order**. Dispatching strategies are evaluated **in order**.
Line 1023: Line 1023:
  
  
-===== 7.2.10 Common Pitfalls =====+==== 7.2.10 Common Pitfalls ====
  
   * depot names not matching the depots table   * depot names not matching the depots table
Line 1037: Line 1037:
 ===== 8) Career Mode (Optional) ===== ===== 8) Career Mode (Optional) =====
  
-`loadCareerMode()` is optional and currently empty.+Career Mode is optional.   
 +If you don’t want career mode features on your map, you can leave `loadCareerMode()` empty.
  
-This is where career mode related data can be initialized later.+If you *do* want career mode, this function defines: 
 + 
 +  * where the player is allowed to take over a train 
 +  * optional route closures (for scenario logic) 
 +  * which train compositions the player is likely to get 
 +  * which timetable templates are used for pathfinding 
 + 
 +==== 8.1 Takeover Stations (Where the Player Can Start) ==== 
 + 
 +`self.cmTakeoverStations` is a list of stations where career mode allows a takeover. 
 + 
 +For the TestMap, we keep it simple: 
 + 
 +<code lua> 
 +-- Initializes data for career mode (optional) 
 +function TestMap:loadCareerMode() 
 + 
 + -- Stations where the player can take over in career mode 
 + self.cmTakeoverStations = { 
 + self.stations.TS,   -- TestStation (main terminus) 
 + self.stations.TSA,  -- TestStation Anfang (other terminus) 
 + self.stations.DP,   -- Depot (optional takeover) 
 + }; 
 + 
 +end 
 +</code> 
 + 
 +Notes: 
 +  * You reference the stations from `self.stations` (created in `loadStations()`). 
 +  * If a station is missing here, the player won’t be offered takeovers there. 
 + 
 +==== 8.2 Route Closures (Optional) ==== 
 + 
 +Route closures allow you to define sections that may be blocked in career mode. 
 +This is mainly for scenario systems and future gameplay logic. 
 + 
 +Each closure uses: 
 +  * `stationSource` → start of the closed section 
 +  * `stationTarget` → end of the closed section 
 +  * a DayMask (e.g. `DayMask.Always`, `DayMask.Weekdays`, `DayMask.Weekends`) 
 + 
 +Example for the TestMap (optional): 
 + 
 +<code lua> 
 +function TestMap:loadCareerMode() 
 + 
 + self.cmTakeoverStations = { 
 + self.stations.TS, 
 + self.stations.TSA, 
 + self.stations.DP, 
 + }; 
 + 
 + -- Optional: example closure between TS and TSA on weekends 
 + self.cmRouteClosures = { 
 +
 + stationSource      = self.stations.TS, 
 + stationTarget      = self.stations.TSA, 
 + tempClosure        = DayMask.Weekends, 
 + }, 
 + }; 
 + 
 +end 
 +</code> 
 + 
 +If you don’t need closures, simply omit `self.cmRouteClosures`. 
 + 
 +==== 8.3 cmGroups (Train Pool + Probability) ==== 
 + 
 +`self.cmGroups` defines which train compositions can appear in career mode. 
 + 
 +Each group represents a **probability set** for vehicle selection. 
 + 
 +You can define **multiple groups**. 
 +Each group has: 
 + 
 +^ Field ^ Meaning ^ 
 +| frequency | Probability factor in the range **0.0 – 1.0** | 
 +| compositions | List of composition `contentName` strings | 
 + 
 +Important: 
 +  * `frequency = 1.0` means **100 % chance** for this group to be considered. 
 +  * `frequency = 0.0` disables the group entirely. 
 +  * Values between 0.0 and 1.0 reduce the chance accordingly. 
 +  * The value is **not relative** to other groups. 
 + 
 +==== Example (TestMap) ==== 
 + 
 +<code lua> 
 +function TestMap:loadCareerMode() 
 + 
 + self.cmTakeoverStations = { 
 + self.stations.TS, 
 + self.stations.TSA, 
 + self.stations.DP, 
 + }; 
 + 
 + -- Career mode vehicle selection pool 
 + self.cmGroups = { 
 + -- Main vehicle pool (always available) 
 +
 + frequency = 1.0, 
 + compositions = { 
 + "Berlin_HK_2x", 
 + "Berlin_A3L92_4x", 
 + }, 
 + }, 
 + 
 + -- Optional / rare vehicles 
 +
 + frequency = 0.4, 
 + compositions = { 
 + "Berlin_HK_1x", 
 + "Berlin_A3L92_3x", 
 + }, 
 + }, 
 + }; 
 + 
 +end 
 +</code> 
 + 
 +Result: 
 +  * HK_2x and A3L92_4x are **always available** in career mode. 
 +  * HK_1x and A3L92_3x appear **only occasionally**, depending on the random selection. 
 + 
 +==== 8.4 Pathfinding Templates ==== 
 + 
 +Career mode also needs timetable templates that can be used for route finding. 
 + 
 +For the TestMap, we reference our two templates: 
 + 
 +<code lua> 
 +function TestMap:loadCareerMode() 
 + 
 + self.cmTakeoverStations = { 
 + self.stations.TS, 
 + self.stations.TSA, 
 + self.stations.DP, 
 + }; 
 + 
 + self.cmGroups = { 
 +
 + frequency = 1, 
 + compositions = { 
 + "Berlin_HK_2x", 
 + "Berlin_A3L92_4x", 
 + }, 
 + }, 
 + }; 
 + 
 + -- Templates that can be used for pathfinding 
 + self.pathfindingTemplates = { 
 + self.TestLine_Dir1, 
 + self.TestLine_Dir2, 
 + }; 
 + 
 +end 
 +</code> 
 + 
 +If you forget this, career mode may not be able to plan valid routes on your map.
  
 ---- ----
Line 1059: Line 1218:
   * AI traffic will not work   * AI traffic will not work
   * stations may not be recognized for routing   * stations may not be recognized for routing
 +
 +----
 +
 +===== Final Step – Build & Test the Map =====
 +
 +If all steps on this page were completed successfully, your map is now **fully configured**:
 +
 +  * the level exists and loads correctly
 +  * tracks, signals, and stations are set up
 +  * Map.lua is registered and contains stations, timetables, dispatching, and optional career data
 +
 +At this point, the map can be built and tested for the first time inside **SubwaySim 2**.
 +
 +Continue with:
 +  * [[manual:subwaysim:map_construction:build_mod|Build Mod (.pak)]]
 +
 +This step explains how to:
 +  * build your plugin
 +  * start SubwaySim 2 with your mod enabled
 +  * verify that the map loads correctly in-game
 +
 +----
 +
 +===== Additional Resources =====
 +
 +For further reference and updates, the following resources are recommended:
 +
 +
 +
 +=== SDK Changelog === 
 +
 +Stay up to date with changes, fixes, and new features in the Modding SDK:  
 +    * [[manual:sdk_changelog|SDK Changelog]]
 +
 +=== SDK Download & Test Content ===
 +
 +The SDK download area contains:
 +   * the current Modding SDK
 +   * the official **TestMap** used in this documentation
 +   * additional reference content for modders  
 +
 +   * [[manual:sdk_download|SDK Download]]
 +
 +The downloadable **TestMap** is provided as a **separate reference project**, distinct from the Sample Mod Map.  
 +While the Sample Map demonstrates general concepts, the TestMap mirrors the map structure built step by step throughout this documentation.
  
 {{page>manual:footer}} {{page>manual:footer}}
  
manual/subwaysim/map_construction/create_maplua.1768396105.txt.gz · Last modified: by dcs

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki