construction_util_serialized¶
Source: base/tealdef/scripts/construction/construction_util_serialized.d.tl
Plain lua table type definitions for construction resource scripts. These types describe the format of lua tables produced by construction scripts and read by C++ via converters. They must NOT reference C++ userdata types.
Example
-- a module update script (base/content/landmarks/hq/hq/headquarter_addon.script.tl, shortened)
local constructionutil = ug_require "::/scripts/construction/constructionutil.lua" as ConstructionUtilSerialized
function data.updateFn(captureParams : table, result : HeadquarterUtilSerialized.HeadquarterConstructionResult, _transform : Mat4Serialized.Mat4,
tag : string, slotId : integer, _addModelFnInvalid : function(), params : ConstructionUtilSerialized.ModuleUpdateFnParams)
local transf2 = result.slots[result.slotIds[slotId]].transf
local generatedData = captureParams.generatedData as ConstructionUtilSerialized.GeneratedData
constructionutil.addModelsAndGroups(params, generatedData as ConstructionUtilSerialized.GeneratedDataGroup, result.subconstructions[1], tag, transf2)
end
ConstructionUtilSerialized¶
record global base/tealdef/scripts/construction/construction_util_serialized.d.tl:3
global record ConstructionUtilSerialized
Notes
Plain-table types of what construction scripts (updateFn, module updateFn, getModelsFn,
createTemplateFn) return; the engine converts these tables. The legacy helper
/scripts/construction/constructionutil.lua is loaded with this type to get addModelsAndGroups.
Types
| Name | Definition | Description |
|---|---|---|
GeneratedData |
{string : GeneratedDataGroup} |
Generated data by group name (e.g. "static", "base", "variant_0"). |
ConstructionTemplateResult |
{integer : string} |
Result of a createTemplateFn: module file per slot id, i.e. the modules a new construction starts with. The headquarter uses { [rootSlotId] = "::/landmarks/hq/modules/hq_main.module" }. |
ModelsFnData |
{TransformedModel} |
Return value of a module's getModelsFn, the module's models with their transforms. |
Functions
addModelsAndGroups(params : any, group : GeneratedDataGroup, subconstruction : SubConstruction, tag? : string, transf2? : Mat4Serialized.Mat4) base/tealdef/scripts/construction/construction_util_serialized.d.tl:265
Notes
Adds everything a generated data group describes to a subconstruction: its models, random models from asset groups, ground faces, terrain alignment and colliders.
| Parameter | Type | Description |
|---|---|---|
params |
any |
The construction parameters; params.seed is required (it seeds the random group choices). |
group |
GeneratedDataGroup |
The generated data group. |
subconstruction |
SubConstruction |
Where models, ground faces, alignment lists and colliders are appended. |
tag? |
string |
Optional tag set on the added models. |
transf2? |
Mat4Serialized.Mat4 |
Optional transform applied to everything that is added. |
Details
Implemented in /scripts/construction/constructionutil.lua; load that file with
ug_require "::/scripts/construction/constructionutil.lua" as ConstructionUtilSerialized.
Asset groups are looked up first in params.state.groups, then in AssetUtil.assets; a missing group
logs a warning and uses a placeholder model.
ConstructionUtilSerialized.ScriptRef¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:8
record ScriptRef
Notes
Reference to a script function as "file.script@function" plus the parameters passed to it.
Used in the base game: 1 time in 1 file
base/content/scripts/scripts/construction/construction.script.tl:16
Fields
| Name | Type | Description |
|---|---|---|
fileName |
string |
Script function reference, e.g. "small_stops.script@updateFn". |
params |
table |
Table passed to the function as its first argument (captureParams). |
ConstructionUtilSerialized.TransportMode¶
enum base/tealdef/scripts/construction/construction_util_serialized.d.tl:13
enum TransportMode
Notes
Transport mode names used in lane lists, depots, snap points and terminals; the same set as api.type.TransportMode.
ConstructionUtilSerialized.BaseEdgeType¶
enum base/tealdef/scripts/construction/construction_util_serialized.d.tl:32
enum BaseEdgeType
Notes
Kind of an edge list's edges.
| Value | Description |
|---|---|
"NORMAL" |
Ordinary edge on the ground. |
"BRIDGE" |
Bridge; the bridge type goes into edgeTypeName. |
"TUNNEL" |
Tunnel; the tunnel type goes into edgeTypeName. |
ConstructionUtilSerialized.CatchmentArea¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:38
record CatchmentArea
Notes
Cylinder with a radius around a position; it is the area a station, stop or depot covers.
Fields
| Name | Type | Description |
|---|---|---|
position |
Vec3Serialized.Vec3 |
Centre, in construction-local coordinates (the base game writes {0, 0, 0}). |
radius |
number |
Radius in metres. |
ConstructionUtilSerialized.CargoTypeSet¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:43
record CargoTypeSet
Notes
Selects cargo types by class and by type, with include and exclude lists.
Fields
ConstructionUtilSerialized.SlotConfig¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:50
record SlotConfig
Notes
Extra settings for all slots of one slot type (key of slotConfig).
Fields
ConstructionUtilSerialized.StreetTerminal¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:56
record StreetTerminal
Notes
Terminal of a street-side stop (an edge object such as the small bus and truck stops).
Fields
| Name | Type | Description |
|---|---|---|
capacity |
integer |
Number of passengers or cargo units that can wait. |
cargo |
boolean |
Whether the stop handles cargo. |
passengers |
boolean |
Whether the stop handles passengers. |
cargoLoad |
boolean |
Whether cargo can be loaded. |
passengersLoad |
boolean |
Whether passengers can board. |
cargoUnload |
boolean |
Whether cargo can be unloaded. |
passengersUnload |
boolean |
Whether passengers can alight. |
comfortFactor |
number |
How quickly the happiness of waiting passengers decreases. |
wantSymmetric |
boolean |
True for stops on both sides of the street (the small stops set it from their twoSided parameter). |
catchmentArea |
CatchmentArea |
Catchment area of the stop. |
cargoTransferSpeeds |
{TerminalDef.CargoTransferSpeed} |
Loading speed settings per cargo type set. |
ConstructionUtilSerialized.GeneratedDataGroup¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:70
record GeneratedDataGroup
Notes
One group of data exported from the model editor (the generatedData tables in construction scripts):
named curves and model placements.
Used in the base game: 6 times in 3 files
base/content/landmarks/landmark_util_serialized.tl:10
local function addTerminals(params, generatedData : ConstructionUtilSerialized.GeneratedDataGroup, terminals, mainSubconstruction : ConstructionUtilSerialized.S
base/content/landmarks/hq/hq/headquarter_addon.script.tl:59
constructionutil.addModelsAndGroups(params, generatedData as ConstructionUtilSerialized.GeneratedDataGroup, result.subconstructions[1], tag, transf2)
base/content/stations/air/air/heliport/modules.script.tl:59
Types
Fields
| Name | Type | Description |
|---|---|---|
curves |
GeneratedCurve |
Named curves of the group. |
models |
{string : {Mat4Serialized.Mat4}} |
Model placements; each key is a model file and maps to the list of its transforms. |
ConstructionUtilSerialized.ModuleUpdateFnParams¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:78
record ModuleUpdateFnParams
Notes
Parameters passed to a modular construction's update script and to each module's update script.
Used in the base game: 5 times in 3 files
base/content/landmarks/hq/hq/headquarter_addon.script.tl:8
base/content/stations/air/air/heliport/modules.script.tl:8
base/content/scripts/scripts/construction/construction.script.tl:17
Fields
| Name | Type | Description |
|---|---|---|
seed |
integer |
Random seed; while a module script runs it is the construction's seed plus the slot id. |
modules |
{integer : Module} |
Placed modules by slot id; modules are processed in ascending slot id order. |
ConstructionUtilSerialized.ModuleUpdateFnParams.Module¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:79
record Module
Notes
One module placed in a slot.
Fields
| Name | Type | Description |
|---|---|---|
updateScript |
ScriptRef |
The module's update script; called with its params, the construction result, the slot transform, a tag, the slot id, an add-model function and these parameters. |
metadata |
any |
The module's metadata, e.g. price, maintenanceCost, bulldozePrice. |
name |
string |
The module's resource name. |
variant |
integer |
Changed with M/N while placing the module. Can be negative, default 0. The headquarter uses it as a rotation in quarter turns. |
ConstructionUtilSerialized.ModuleGetModelsFnParams¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:89
record ModuleGetModelsFnParams
Notes
Parameters of a module's getModelsFn (no fields are defined).
Used in the base game: 2 times in 2 files
base/content/landmarks/hq/hq/headquarter_addon.script.tl:100
function data.getModelsFn(captureParams : table, _params : ConstructionUtilSerialized.ModuleGetModelsFnParams) : ConstructionUtilSerialized.ModelsFnData
base/content/stations/air/air/heliport/modules.script.tl:58
ConstructionUtilSerialized.TransformedModel¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:92
record TransformedModel
Notes
A model placed by a construction.
Used in the base game: 4 times in 1 file
base/content/scripts/scripts/construction/construction.script.tl:85
Fields
| Name | Type | Description |
|---|---|---|
id |
string |
Model file, e.g. "station/rail/platform.mdl". |
transf |
Mat4Serialized.Mat4 |
Placement transform (16 numbers, column-major) relative to the construction. |
tag |
string |
Tag of the model; models added by a module get "__module_<slotId>", which links them to that module. |
ConstructionUtilSerialized.GroundFace¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:98
record GroundFace
Notes
A ground texture face (face points and texture modes); no fields are declared in the definition.
ConstructionUtilSerialized.TerrainAlignmentList¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:101
record TerrainAlignmentList
Notes
A set of faces to which the terrain is adapted.
Used in the base game: 1 time in 1 file
base/content/landmarks/hq/hq/headquarter.script.tl:352
Fields
| Name | Type | Description |
|---|---|---|
type |
AlignmentType |
Alignment type. |
faces |
{{{number, number, number}}} |
Polygons, each a list of {x, y, z} points. |
slopeLow |
number |
Embankment slope at the face border (the base game uses e.g. 0.275). |
slopeHigh |
number |
Maximum embankment slope (the base game uses e.g. 0.6). |
ConstructionUtilSerialized.TerrainAlignmentList.AlignmentType¶
enum base/tealdef/scripts/construction/construction_util_serialized.d.tl:102
enum AlignmentType
Notes
How the terrain is adapted to the faces.
| Value | Description |
|---|---|
"EQUAL" |
Terrain is set to the height of the faces. |
"LESS" |
Terrain is lowered where it is higher than the faces. |
"GREATER" |
Terrain is raised where it is lower than the faces. |
ConstructionUtilSerialized.Slot¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:113
record Slot
Notes
A slot of a modular construction, where modules of the same type can be placed.
Fields
| Name | Type | Description |
|---|---|---|
id |
integer |
Unique slot id; modules in params.modules are keyed by it. Can encode the slot's coordinates. |
transf |
Mat4Serialized.Mat4 |
Transform relative to the construction origin; module models are placed relative to it. |
type |
string |
Slot type; only modules of the same type can be built here. |
spacing |
{number, number, number, number} |
Extent of the slot around its origin, {left, right, south, north}: distances along -X, +X, -Y and +Y in slot coordinates. |
height |
number |
Height of the slot for collision. |
shape |
integer |
0 = square, 1 = triangle, 2 = transverse rectangle, 3 = longitudinal rectangle. |
autoFill |
boolean |
Fills the slot automatically when the construction spawns (fields use it to add their satellites). |
alignToTerrain |
boolean |
Moves the slot vertically to the terrain height (used e.g. for fields). |
replaceable |
boolean |
Modules in this slot can be replaced by other modules of the same type without bulldozing first. |
ConstructionUtilSerialized.Depot¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:127
record Depot
Notes
Depot part of a subconstruction.
Fields
| Name | Type | Description |
|---|---|---|
catchmentArea |
CatchmentArea |
Area around the depot in which vehicles are maintained. |
transportModes |
{TransportMode} |
Transport modes of the vehicles the depot handles. |
maintenancePool |
integer |
Number of vehicles that can be maintained at the same time. |
ConstructionUtilSerialized.Industry¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:133
record Industry
Notes
Industry part of a subconstruction.
Fields
| Name | Type | Description |
|---|---|---|
productionLevel |
integer |
Current production level. |
maxLevel |
integer |
Highest production level. |
ConstructionUtilSerialized.EdgeListType¶
enum base/tealdef/scripts/construction/construction_util_serialized.d.tl:138
enum EdgeListType
Notes
Network type of an edge list.
| Value | Description |
|---|---|
"STREET" |
Street edges. |
"TRACK" |
Track edges. |
ConstructionUtilSerialized.EdgeList¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:143
record EdgeList
Notes
Street or track edges a construction creates in the transport network.
Fields
| Name | Type | Description |
|---|---|---|
edgeType |
BaseEdgeType |
Normal, bridge or tunnel. |
edgeTypeName |
string |
Bridge or tunnel type used when edgeType is BRIDGE or TUNNEL. |
type |
EdgeListType |
Street or track. |
edges |
{{Vec3Serialized.Vec3, Vec3Serialized.Vec3}} |
Nodes as {position, tangent} pairs; every two consecutive entries form one edge. Build them with StreetUtilSerialized.addStraightEdge, addEdge and friends. |
snapNodes |
{integer} |
0-based indices of the nodes in edges that snap to existing streets or tracks. |
freeNodes |
{integer} |
0-based indices of the nodes in edges that are not frozen to the construction (see StreetUtilSerialized.freeAllNodes). |
trafficLightYes |
{integer} |
|
trafficLightNo |
{integer} |
|
tag2nodes |
{string : {integer}} |
Named groups of node indices (0-based) for later reference. |
alignTerrain |
boolean |
ConstructionUtilSerialized.LaneList¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:156
record LaneList
Notes
Lanes inside a construction (paths for persons, cargo and vehicles that are not streets or tracks).
Fields
| Name | Type | Description |
|---|---|---|
transf |
Mat4Serialized.Mat4 |
Transform applied to the lane nodes. |
transportModes |
{TransportMode} |
Transport modes allowed on the lanes. |
speedLimit |
number |
Speed limit of the lanes. In m/s. |
nodes |
{{Vec3Serialized.Vec3, Vec3Serialized.Vec3, number}} |
Nodes as {position, tangent, width}; every two consecutive entries form one lane edge (see LaneUtilSerialized.createLane). |
linkable |
boolean |
Whether the automatically generated short footpath links can connect to these lanes. |
pedestrianWalkPenalty |
number |
Penalty for pedestrians walking on these lanes. |
forwardOnly |
boolean |
Lanes may only be travelled in forward direction. |
needsReservation |
boolean |
Lanes need reservation before vehicles may enter. |
ConstructionUtilSerialized.RunwayDef¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:167
record RunwayDef
Notes
A landing or take-off path for aircraft and ships, defined on lane nodes.
Fields
ConstructionUtilSerialized.TerminalDef¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:173
record TerminalDef
Notes
A station terminal, defined on the lanes of its subconstruction.
Fields
| Name | Type | Description |
|---|---|---|
comfortFactor |
number |
How quickly the happiness of waiting passengers decreases. |
personEdges |
{{integer, integer}} |
Edges of the waiting area as {laneListIndex, edgeIndex} pairs (0-based). |
capacity |
integer |
How many passengers or cargo units fit the terminal. |
cargoTransferSpeeds |
{CargoTransferSpeed} |
Loading speed settings. |
ConstructionUtilSerialized.TerminalDef.CargoTransferSpeed¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:174
record CargoTransferSpeed
Notes
Loading speed setting for a set of cargo types.
Fields
| Name | Type | Description |
|---|---|---|
cargoTypeSet |
CargoTypeSet |
Cargo types the setting applies to. |
loadSpeedModifier |
number |
Factor on the loading speed. |
length |
number |
Length of the terminal section. |
ConstructionUtilSerialized.StationDef¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:186
record StationDef
Notes
The station of a subconstruction.
Fields
| Name | Type | Description |
|---|---|---|
pool |
Pool |
Shared waiting area. |
terminals |
{TerminalDef} |
The station's terminals. |
ConstructionUtilSerialized.StationDef.Pool¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:187
record Pool
Notes
Shared waiting area that takes overflowing terminal capacity.
Fields
| Name | Type | Description |
|---|---|---|
capacity |
integer |
Size of the shared pool. |
edges |
{{integer, integer}} |
Edges of the shared waiting area as {laneListIndex, edgeIndex} pairs. |
ConstructionUtilSerialized.StockRules¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:196
record StockRules
Notes
A production rule of an industry-like subconstruction.
Fields
| Name | Type | Description |
|---|---|---|
input |
{{integer}} |
orRule to stock to amount |
output |
{string : integer} |
Produced amounts by output stock. |
capacity |
integer |
Production capacity of the rule. |
ConstructionUtilSerialized.Stocks¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:202
record Stocks
Notes
A cargo stock of a subconstruction.
Fields
| Name | Type | Description |
|---|---|---|
type |
StockType |
Role of the stock. |
cargoType |
string |
Cargo type resource stored. |
capacity |
integer |
Capacity of the stock. |
ConstructionUtilSerialized.Stocks.StockType¶
enum base/tealdef/scripts/construction/construction_util_serialized.d.tl:203
enum StockType
Notes
Role of the stock.
| Value | Description |
|---|---|
"INPUT_STOCK" |
Receives delivered cargo. |
"OUTPUT_STOCK" |
Holds produced cargo for pickup. |
"STORAGE_STOCK" |
Stores cargo. |
ConstructionUtilSerialized.SubConstruction¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:213
record SubConstruction
Notes
One part of a construction result: its models, ground faces, colliders, terrain alignment, lanes and
optionally a station, depot or industry. Most constructions use a single subconstruction
(result.subconstructions[1]).
Used in the base game: 3 times in 2 files
base/content/landmarks/landmark_util_serialized.tl:10
local function addTerminals(params, generatedData : ConstructionUtilSerialized.GeneratedDataGroup, terminals, mainSubconstruction : ConstructionUtilSerialized.S
base/content/landmarks/hq/hq/headquarter.script.tl:493
Fields
| Name | Type | Description |
|---|---|---|
models |
{TransformedModel} |
Placed models. |
groundFaces |
{GroundFace} |
Ground texture faces. |
colliders |
{ColliderUtilSerialized.Collider} |
Collision shapes. |
depot |
Depot |
Depot data, if the subconstruction is a depot. |
terrainAlignmentLists |
{TerrainAlignmentList} |
Terrain alignment. |
laneLists |
{LaneList} |
Lanes; terminals and runways refer to them by 0-based index. |
runways |
{RunwayDef} |
Landing and take-off paths. |
station |
StationDef |
Station data, if the subconstruction is a station. |
industry |
Industry |
Industry data, if the subconstruction is an industry. |
rules |
{StockRules} |
Production rules. |
stocks |
{Stocks} |
Cargo stocks. |
tag |
integer |
Tag identifying the subconstruction (e.g. between upgrades). |
metadata |
table |
Metadata stored with the subconstruction instance. |
ConstructionUtilSerialized.SnapPoint¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:229
record SnapPoint
Notes
Where and to what the construction snaps while it is being placed.
Fields
| Name | Type | Description |
|---|---|---|
snapToBaseEdgeTypes |
{EdgeListType} |
Network types to snap to, e.g. {"STREET"}. |
allowSnapToBaseEdgeEnds |
boolean |
Also allow snapping to the end of a street or track. |
alignWithCoast |
boolean |
Align the construction with the coastline (harbours, ship depots). |
placeAtTerrainHeight |
boolean |
|
transf |
Mat4Serialized.Mat4 |
Snap point transform relative to the construction. |
transportModes |
{TransportMode} |
Transport modes the snap point applies to. |
ConstructionUtilSerialized.IConstructionResult¶
interface base/tealdef/scripts/construction/construction_util_serialized.d.tl:238
interface IConstructionResult
Notes
What a construction's updateFn returns.
Details
Costs are in game currency. If maintenanceCost is nil or 0, the construction script sets it to
cost / 6; cost and bulldozeCost are scaled by the game's infrastructure cost scale.
Example
Used in the base game: 1 time in 1 file
base/content/landmarks/hq/hq/headquarter.script.tl:133
Fields
| Name | Type | Description |
|---|---|---|
subconstructions |
{SubConstruction} |
The construction's parts. |
metadata |
table |
Metadata stored with the built construction (its persistent metadata). |
snapPoint |
SnapPoint |
Snap point used while placing the construction. |
slots |
{Slot} |
Module slots of a modular construction. |
slotConfig |
{string : SlotConfig} |
Extra settings per slot type. |
cost |
number |
Build cost in game currency; module prices are added to it. |
maintenanceCost |
number |
Maintenance cost per year in game currency; defaults to cost / 6. |
streetTerminal |
StreetTerminal |
Terminal data for street-side stops. |
bulldozeCost |
number |
Cost of bulldozing the construction, in game currency. |
noCostAtAll |
boolean |
disable all cost for the entire proposal |
callInvalidModules |
boolean |
Also run the update scripts of modules whose slot id is not in slots. |
Functions
terminateConstructionHook() base/tealdef/scripts/construction/construction_util_serialized.d.tl:256
Only used within constructWithModules
ConstructionUtilSerialized.ConstructionResult¶
record base/tealdef/scripts/construction/construction_util_serialized.d.tl:260
record ConstructionResult is IConstructionResult
Notes
Concrete construction result type (see IConstructionResult).
Used in the base game: 8 times in 2 files
base/content/landmarks/landmark_util_serialized.tl:102
landmark_util_serialized.makeLandmarksUpdateFn = function(generatedData : ConstructionUtilSerialized.GeneratedDataGroup) : function(captureParams : table, param
base/content/scripts/scripts/construction/construction.script.tl:23