tutorial_story_util¶
Source: base/tealdef/mission/tutorial/tutorial_story_util.d.tl
Notes
Helpers of the base-game tutorial story (capital town, industries, areas, vehicle lists).
TutorialStoryUtil¶
record global base/tealdef/mission/tutorial/tutorial_story_util.d.tl:3
global record TutorialStoryUtil
Load: local tutorial_story_util = ug_require "::/mission/tutorial/tutorial_story_util.tl" as TutorialStoryUtil
Notes
Helpers of the base-game tutorial story.
Fields
| Name | Type | Description |
|---|---|---|
TownDistrictRadius |
number |
Radius in metres around a district centre used to find its streets (100). used 31× in the base game |
Functions
getCapital() : Engine.Entity base/tealdef/mission/tutorial/tutorial_story_util.d.tl:5
Call as tutorial_story_util.getCapital(…)
Notes
Returns the tutorial's capital, read from the store_capital task.
Returns Engine.Entity: Town entity, or -1.
Used in the base game: 69 times in 4 files
base/content/mission/mission/tutorial/tasks/tutorial_init.tl:138
industryEntity = tutorial_story_util.getClosestIndustryToTown("::/industries/farm/farm.con", tutorial_story_util.getCapital())
base/content/mission/mission/tutorial/tutorial_story.tl:321
base/content/mission/mission/tutorial/tutorial_story_branch_a.tl:121
local townZone = tutorial_story_util.toPosRadius(tutorial_story_util.getTownDistrictCenterSafe(tutorial_story_util.getCapital(), api.type["enum"].LandUseType.CO
base/content/mission/mission/tutorial/tutorial_story_branch_b.tl:143
getCapitalName() : string base/tealdef/mission/tutorial/tutorial_story_util.d.tl:6
Call as tutorial_story_util.getCapitalName(…)
Notes
Returns the name of the capital.
Returns string: Name, or "ERROR".
Used in the base game: 35 times in 3 files
base/content/mission/mission/tutorial/tutorial_story.tl:558
base/content/mission/mission/tutorial/tutorial_story_branch_a.tl:137
base/content/mission/mission/tutorial/tutorial_story_branch_b.tl:138
getSecondTown() : Engine.Entity base/tealdef/mission/tutorial/tutorial_story_util.d.tl:7
Call as tutorial_story_util.getSecondTown(…)
Notes
Returns the tutorial's second town, read from the store_town2 task.
Returns Engine.Entity: Town entity, or -1.
getSecondTownName() : string base/tealdef/mission/tutorial/tutorial_story_util.d.tl:8
Call as tutorial_story_util.getSecondTownName(…)
Notes
Returns the name of the second town.
Returns string: Name, or "ERROR".
getPositionSafe(entity : Engine.Entity) : Vec3f base/tealdef/mission/tutorial/tutorial_story_util.d.tl:9
Call as tutorial_story_util.getPositionSafe(…)
Notes
Returns the position of an entity, or nil if the entity is nil or no longer exists.
| Parameter | Type | Description |
|---|---|---|
entity |
Engine.Entity |
Entity to locate. |
Returns Vec3f: Position, or nil.
Used in the base game: 20 times in 3 files
base/content/mission/mission/tutorial/tutorial_story.tl:109
base/content/mission/mission/tutorial/tutorial_story_branch_a.tl:770
tutorial_story_util.toPosRadius(tutorial_story_util.getPositionSafe(getOilPlatform()), tutorial_story_util.TownDistrictRadius),
base/content/mission/mission/tutorial/tutorial_story_branch_b.tl:923
getTownDistrictCenterSafe(town : Engine.Entity, landUseType : LandUseType) : Vec3f base/tealdef/mission/tutorial/tutorial_story_util.d.tl:10
Call as tutorial_story_util.getTownDistrictCenterSafe(…)
Notes
Returns the centre of a town's district of one land-use type, or nil if the town is nil or no longer exists.
| Parameter | Type | Description |
|---|---|---|
town |
Engine.Entity |
Town entity. |
landUseType |
LandUseType |
Residential, commercial or industrial district. |
Returns Vec3f: Position of the district centre, or nil.
Used in the base game: 23 times in 3 files
base/content/mission/mission/tutorial/tutorial_story.tl:688
circle = tutorial_story_util.toPosRadius(tutorial_story_util.getTownDistrictCenterSafe(tutorial_story_util.getCapital(), api.type["enum"].LandUseType.RESIDENTIA
base/content/mission/mission/tutorial/tutorial_story_branch_a.tl:121
local townZone = tutorial_story_util.toPosRadius(tutorial_story_util.getTownDistrictCenterSafe(tutorial_story_util.getCapital(), api.type["enum"].LandUseType.CO
base/content/mission/mission/tutorial/tutorial_story_branch_b.tl:190
getCapitalCargoDemand(cargoTypeRes : string) : number base/tealdef/mission/tutorial/tutorial_story_util.d.tl:11
Call as tutorial_story_util.getCapitalCargoDemand(…)
Notes
Returns how much of a cargo the capital demands.
| Parameter | Type | Description |
|---|---|---|
cargoTypeRes |
string |
Cargo type file, as api.res.cargoTypeRep.find takes it. |
Returns number: The demand (the second value of townBuildingSystem.getCargoSupplyAndLimit), or 0 without a capital or for a cargo the town does not use.
Used in the base game: 4 times in 2 files
base/content/mission/mission/tutorial/tutorial_story_branch_a.tl:383
base/content/mission/mission/tutorial/tutorial_story_branch_b.tl:484
getStoredEntity(taskKey : string) : Engine.Entity base/tealdef/mission/tutorial/tutorial_story_util.d.tl:12
Call as tutorial_story_util.getStoredEntity(…)
Notes
Returns the entity stored by the store_entity task with the given key. The tutorial uses it for the oil platform, refinery, fishing grounds and forest.
| Parameter | Type | Description |
|---|---|---|
taskKey |
string |
Key of the store_entity task. |
Returns Engine.Entity: The entity, or nil if the task is missing, has not stored one yet, or the entity no longer exists (an error is logged once).
Used in the base game: 8 times in 3 files
base/content/mission/mission/tutorial/tutorial_story.tl:324
base/content/mission/mission/tutorial/tutorial_story_branch_a.tl:53
base/content/mission/mission/tutorial/tutorial_story_branch_b.tl:53
toPosRadius(pos : Vec3f, radius : number) : MissionInterface.PosRadius base/tealdef/mission/tutorial/tutorial_story_util.d.tl:13
Call as tutorial_story_util.toPosRadius(…)
Notes
Builds an area from a position and a radius.
| Parameter | Type | Description |
|---|---|---|
pos |
Vec3f |
Centre. |
radius |
number |
Radius in metres. |
Returns MissionInterface.PosRadius: Area.
Used in the base game: 37 times in 3 files
base/content/mission/mission/tutorial/tutorial_story.tl:688
circle = tutorial_story_util.toPosRadius(tutorial_story_util.getTownDistrictCenterSafe(tutorial_story_util.getCapital(), api.type["enum"].LandUseType.RESIDENTIA
base/content/mission/mission/tutorial/tutorial_story_branch_a.tl:121
local townZone = tutorial_story_util.toPosRadius(tutorial_story_util.getTownDistrictCenterSafe(tutorial_story_util.getCapital(), api.type["enum"].LandUseType.CO
base/content/mission/mission/tutorial/tutorial_story_branch_b.tl:190
getBaseEdgesInDistrictType(landUseType : LandUseType) : {Engine.Entity} base/tealdef/mission/tutorial/tutorial_story_util.d.tl:14
Call as tutorial_story_util.getBaseEdgesInDistrictType(…)
Notes
Returns the street edges within TownDistrictRadius of the capital's district centre of a land-use type.
| Parameter | Type | Description |
|---|---|---|
landUseType |
LandUseType |
District type. |
Returns {Engine.Entity}: Edge entities.
makeStopConfig(edges : {Engine.Entity}) : BuildConstructionUtil.ProposalHandlerConfig base/tealdef/mission/tutorial/tutorial_story_util.d.tl:15
Call as tutorial_story_util.makeStopConfig(…)
Notes
Builds a proposal check that accepts only street stops placed on the given edges.
In game Not a Stop!
· Not a Station!
· Only possible in the highlighted area.
In code: MISSION_PROPOSAL_FEEDBACK_NOT_IN_OUTLINED_AREA
| Parameter | Type | Description |
|---|---|---|
edges |
{Engine.Entity} |
Allowed edges. |
Returns BuildConstructionUtil.ProposalHandlerConfig: Proposal handler config.
getDepotPosition() : {number, number, number} base/tealdef/mission/tutorial/tutorial_story_util.d.tl:16
Call as tutorial_story_util.getDepotPosition(…)
Notes
Returns the depot position stored by the store_depot_position task.
Returns {number, number, number}: Position {x, y, z}, or nil.
Used in the base game: 8 times in 3 files
base/content/mission/mission/tutorial/tutorial_story.tl:937
links = { entity_depot = { getLocation = function() : MissionInterface.PosRadius return { pos = tutorial_story_util.getDepotPosition(), radius = DepotRadius } e
base/content/mission/mission/tutorial/tutorial_story_branch_a.tl:258
entity_depot = { getLocation = function() : MissionInterface.PosRadius return { pos = tutorial_story_util.getDepotPosition(), radius = IndustryRadius } end },
base/content/mission/mission/tutorial/tutorial_story_branch_b.tl:349
getAllBusTypes() : {string : integer} base/tealdef/mission/tutorial/tutorial_story_util.d.tl:17
Call as tutorial_story_util.getAllBusTypes(…)
Notes
Returns every land vehicle model that carries passengers, each with limit 10.
Returns {string : integer}: Model name -> 10.
getAllTrucksWithClasses(allowedClasses : {string}) : {string : integer} base/tealdef/mission/tutorial/tutorial_story_util.d.tl:18
Call as tutorial_story_util.getAllTrucksWithClasses(…)
Notes
Returns every land vehicle model that carries one of the given cargo classes, each with limit 10.
| Parameter | Type | Description |
|---|---|---|
allowedClasses |
{string} |
Cargo classes. |
Returns {string : integer}: Model name -> 10.
makeDisabledListExcept(exceptions? : {string}) : {string} base/tealdef/mission/tutorial/tutorial_story_util.d.tl:19
Call as tutorial_story_util.makeDisabledListExcept(…)
Notes
Returns the list of construction and management menu ids the tutorial disables, minus the exceptions.
| Parameter | Type | Description |
|---|---|---|
exceptions? |
{string} |
Menu ids to keep enabled. |
Returns {string}: Menu ids.
Used in the base game: 35 times in 3 files
base/content/mission/mission/tutorial/tutorial_story.tl:395
base/content/mission/mission/tutorial/tutorial_story_branch_a.tl:147
base/content/mission/mission/tutorial/tutorial_story_branch_b.tl:149
getClosestIndustryToTown(conName : ResName, townEntity : Engine.Entity) : Engine.Entity base/tealdef/mission/tutorial/tutorial_story_util.d.tl:20
Call as tutorial_story_util.getClosestIndustryToTown(…)
Notes
Returns the industry of a construction type closest to a town; one in the town's area wins.
| Parameter | Type | Description |
|---|---|---|
conName |
ResName |
Construction file of the industry. |
townEntity |
Engine.Entity |
Town. |
Returns Engine.Entity: Industry entity, or -1.
getIndustryToConnect() : Engine.Entity base/tealdef/mission/tutorial/tutorial_story_util.d.tl:21
Call as tutorial_story_util.getIndustryToConnect(…)
Notes
Returns the industry whose road the tutorial init task removed.
Returns Engine.Entity: Industry entity, or -1.
Used in the base game: 21 times in 3 files
base/content/mission/mission/tutorial/tutorial_story.tl:323
base/content/mission/mission/tutorial/tutorial_story_branch_a.tl:120
local industryZone = tutorial_story_util.makeAreaForIndustryRoadSegment(tutorial_story_util.getIndustryToConnect())
base/content/mission/mission/tutorial/tutorial_story_branch_b.tl:121
calcAnnualShipmentSafe(industryEntity : Engine.Entity) : integer base/tealdef/mission/tutorial/tutorial_story_util.d.tl:22
Call as tutorial_story_util.calcAnnualShipmentSafe(…)
Notes
Returns the annual shipment of an industry, or 0 if the entity is nil or no longer exists.
| Parameter | Type | Description |
|---|---|---|
industryEntity |
Engine.Entity |
Industry entity. |
Returns integer: Annual shipment, or 0.
Used in the base game: 4 times in 2 files
base/content/mission/mission/tutorial/tutorial_story_branch_a.tl:395
base/content/mission/mission/tutorial/tutorial_story_branch_b.tl:496
makeAreaForIndustry(entity : Engine.Entity, radius : number) : MissionInterface.PosRadius base/tealdef/mission/tutorial/tutorial_story_util.d.tl:23
Call as tutorial_story_util.makeAreaForIndustry(…)
Notes
Builds a circle at an industry construction's position.
| Parameter | Type | Description |
|---|---|---|
entity |
Engine.Entity |
Industry entity. |
radius |
number |
Radius in metres. |
Returns MissionInterface.PosRadius: Area, or nil.
makeAreaForIndustryRoadSegment(entity : Engine.Entity) : MissionInterface.PosRadius base/tealdef/mission/tutorial/tutorial_story_util.d.tl:24
Call as tutorial_story_util.makeAreaForIndustryRoadSegment(…)
Notes
Builds a 20 m circle at the start of the industry construction's first frozen edge.
| Parameter | Type | Description |
|---|---|---|
entity |
Engine.Entity |
Industry entity. |
Returns MissionInterface.PosRadius: Area, or nil.
constructPolygonForWaterIndustry(entity : Engine.Entity) : PolygonUtil.Polygon base/tealdef/mission/tutorial/tutorial_story_util.d.tl:25
Call as tutorial_story_util.constructPolygonForWaterIndustry(…)
Notes
Builds a convex polygon around the water body of a water industry, extended 200 m onto land.
| Parameter | Type | Description |
|---|---|---|
entity |
Engine.Entity |
Industry entity. |
Returns PolygonUtil.Polygon: Polygon.
Used in the base game: 2 times in 2 files
base/content/mission/mission/tutorial/tutorial_story_branch_a.tl:91
base/content/mission/mission/tutorial/tutorial_story_branch_b.tl:91
hasAnySingleVehicleSupplyLine(pos1 : {MissionInterface.PosRadius}, pos2 : {MissionInterface.PosRadius}, cargoTypeRes : string) : boolean base/tealdef/mission/tutorial/tutorial_story_util.d.tl:26
Call as tutorial_story_util.hasAnySingleVehicleSupplyLine(…)
Notes
Tells whether a player road line between any of the start and end areas has exactly one vehicle that can carry the cargo.
| Parameter | Type | Description |
|---|---|---|
pos1 |
{MissionInterface.PosRadius} |
Start areas. |
pos2 |
{MissionInterface.PosRadius} |
End areas. |
cargoTypeRes |
string |
Cargo type resource. |
Returns boolean: true if such a line exists.