transformator_util¶
Source: base/tealdef/scripts/transformator_util.d.tl
Notes
Types for transformator scripts, the per-frame scripts that animate vehicle and building models
(wheels, doors, lights, pantographs, emitted person models, particles). TransformatorParams is what
an update function receives; TransformatorUtil (/scripts/transformator_util.tl) holds the shared
animation helpers the base game's transformators call.
Example
-- from base/content/vehicle/tram/shared/shared/transformator_tram.script.tl
local updateFnTram = function(__captureParams : NativeLuaTable, params : TransformatorParams, transfsOutput : Transformator.TransfOutput)
if params.currentInfo.landVehicle ~= nil then
local time = transformator_util.getEntityTime(params.currentInfo.world.gameTime, params.entityId)
transformator_util.addDriveAnimationState(params.currentInfo.landVehicle.wheelAnimationInfo.totalDist, params.currentInfo.landVehicle.reversed, transfsOutput)
transformator_util.addDoorAnimationState(params.currentInfo.vehicle.doorAnimationInfo, transfsOutput)
transformator_util.addBrakeLightsAnimationState(params.currentInfo.landVehicle.brakingTimer, time, transfsOutput)
end
end
return { tram = { updateFn = updateFnTram, updateParticleSystemFn = transformator_util.updateParticleSystemFn } }
Globals¶
Types
| Name | Definition | Description |
|---|---|---|
UpdateFn |
function(captureParams : any, transformatorParams : TransformatorParams, transfsOutput : Transformator.TransfOutput) |
Signature of a transformator update function: receives the capture parameters, the TransformatorParams and the output object, on which it sets animation states and user transforms. |
UpdateParticleSystemFn |
function(captureParams : any, transformatorParams : TransformatorParams, Transformator.ParticleSystem) |
Signature of a transformator particle update function (see TransformatorUtil.updateParticleSystemFn). |
GetEmittableModelsFn |
function(captureParams : any, transformatorParams : TransformatorParams) : {string} |
Signature of a function that lists the model files a transformator may emit. |
ComputeEmittedModelsFn |
function(captureParams : any, transformatorParams : TransformatorParams, modelEmitter : Transformator.ModelEmitter) |
Signature of a function that emits models through the ModelEmitter in each update. |
TransformatorParams¶
record global base/tealdef/scripts/transformator_util.d.tl:3
global record TransformatorParams
Notes
Everything a transformator update function receives about the model instance it animates: current and
previous dynamic info, static vehicle info, model metadata and the params table from the model's
transformatorConfig.
Fields
| Name | Type | Description |
|---|---|---|
previousInfo |
DynamicInfo |
Dynamic info of the previous update. |
currentInfo |
DynamicInfo |
Dynamic info of the current update. |
landVehicleApi |
Transformator.LandVehicleScriptingApi |
Queries along the vehicle's path, e.g. getAverageCatenaryHeight and getAverageCurvature. |
vehicleStaticInfo |
Transformator.VehicleStaticScriptingInfo |
Static (non-changing) info of the vehicle. |
aircraftStaticInfo |
Transformator.AircraftStaticScriptingInfo |
Static info of the aircraft. |
modelMetadataInfo |
Transformator.ModelMetadataInfo |
Model metadata available to the transformator, e.g. seats. |
entityId |
Engine.Entity |
Entity id of the model instance. |
instIndex |
integer |
Index of the model instance within the entity; compared with seat.instanceIndex. |
transformatorConfigParams |
any |
The transformatorConfig.params table from the model's metadata (e.g. ModelParamsTram). |
TransformatorParams.TransformatorLanes¶
record base/tealdef/scripts/transformator_util.d.tl:5
record TransformatorLanes
Notes
transformatorConfig.params layout for town buildings that emit moving models along curves; read by
TransformatorUtil.getEmittableModelsTownbuildingFn and computeEmittedModelsTownbuildingFn.
Used in the base game: 2 times in 1 file
base/content/scripts/scripts/transformator_util.tl:52
Fields
| Name | Type | Description |
|---|---|---|
lanes |
{Curve} |
The lanes. |
TransformatorParams.TransformatorLanes.Curve¶
record base/tealdef/scripts/transformator_util.d.tl:6
record Curve
Notes
One lane of emitted models.
Fields
| Name | Type | Description |
|---|---|---|
curves |
ConstructionUtilSerialized.GeneratedDataGroup.GeneratedCurve |
Curves (start point, tangents, end point) along which the models move. |
speed |
number |
Travel time per metre of curve; one pass along a curve takes speed * length game-time units. |
density |
number |
Number of emitted models per metre of curve. |
model |
string |
Model file to emit. |
tags |
string |
Optional industry-state filter: contains idle, prod_low, prod_high and/or boost; the lane is shown only in the matching production state. |
TransformatorParams.ModelParamsHelicopter¶
record base/tealdef/scripts/transformator_util.d.tl:17
record ModelParamsHelicopter
Notes
transformatorConfig.params of helicopters.
Used in the base game: 1 time in 1 file
base/content/vehicle/shared/shared/transformator_air.script.tl:20
Fields
| Name | Type | Description |
|---|---|---|
vtol |
boolean |
True for aircraft that keep rotor pitch up at low horizontal speed (vertical take-off). |
TransformatorParams.ModelParamsTram¶
record base/tealdef/scripts/transformator_util.d.tl:22
record ModelParamsTram
Notes
transformatorConfig.params of trams and other vehicles with a pantograph.
Used in the base game: 1 time in 1 file
base/content/vehicle/tram/shared/shared/transformator_tram.script.tl:47
Fields
TransformatorParams.ModelParamsZeppelin¶
record base/tealdef/scripts/transformator_util.d.tl:29
record ModelParamsZeppelin
Notes
transformatorConfig.params of zeppelins: models emitted on the crew and passenger seats.
Used in the base game: 2 times in 2 files
base/content/vehicle/zeppelin/shared/shared/transformator_zeppelin.script.tl:84
local transformatorConfigParamsZeppelin = params.transformatorConfigParams as TransformatorParams.ModelParamsZeppelin
dlcs/urbangames_deluxe_upgrade_pack/content/vehicle/vehicle/zeppelin/hot_air_balloon/hot_air_balloon.script.tl:24
Fields
TransformatorParams.DynamicInfo¶
record base/tealdef/scripts/transformator_util.d.tl:37
record DynamicInfo
Dynamic Info that will update every render step
Fields
| Name | Type | Description |
|---|---|---|
world |
Transformator.WorldScriptingInfo |
World info such as gameTime. |
vehicle |
Transformator.VehicleScriptingInfo |
Info of any vehicle (speed, velocity, doors, maintenance, ...); nil for non-vehicles. |
roadVehicle |
Transformator.RoadVehicleScriptingInfo |
Road vehicle info; nil for other models. |
railVehicle |
Transformator.RailVehicleScriptingInfo |
Rail vehicle info (weight, axles, brake deceleration, ...); nil for other models. |
tram |
Transformator.TramScriptingInfo |
Tram info; nil for other models. |
landVehicle |
Transformator.LandVehicleScriptingInfo |
Info shared by land vehicles (reversed, side, wheel animation, braking, turn signals). |
aircraft |
Transformator.AircraftScriptingInfo |
Aircraft info; nil for other models. |
ship |
Transformator.ShipScriptingInfo |
Ship info; nil for other models. |
airWaterVehicle |
Transformator.AirWaterVehicleScriptingInfo |
Info shared by aircraft and ships. |
industry |
Transformator.IndustryScriptingInfo |
Industry info (producing, boosting, workplaces) for industry buildings. |
station |
Transformator.StationScriptingInfo |
Station info for station models. |
townBuilding |
Transformator.TownBuildingScriptingInfo |
Town building info for town buildings. |
personCapacity |
Transformator.PersonCapacityInfo |
Persons currently in the model (simPersons), used to emit person models on seats. |
modelPerson |
any |
|
modelPersonIdle |
any |
|
customState |
any |
Script-defined custom state of the entity (the zeppelin transformator reads its era from it). |
TransformatorUtil¶
record global base/tealdef/scripts/transformator_util.d.tl:76
global record TransformatorUtil
Load: local transformator_util = ug_require "::/scripts/transformator_util.tl"
Notes
Shared transformator helpers returned by ug_require "::/scripts/transformator_util.tl".
Fields
| Name | Type | Description |
|---|---|---|
updateParticleSystemFn |
UpdateParticleSystemFn |
Default particle update for vehicles: scales smoke size, life time and frequency with power output and maintenance, tints particles by type (steam_chimney, cylinder, diesel) and stops emission in tunnels. used 10× in the base game |
getEmittableModelsTownbuildingFn |
GetEmittableModelsFn |
Returns the model of every lane in TransformatorLanes, so the engine can load them. used 3× in the base game |
computeEmittedModelsTownbuildingFn |
ComputeEmittedModelsFn |
Emits person models on the model's seats for the persons in personCapacity, and moving models along the TransformatorLanes curves (filtered by industry state via tags). used 3× in the base game |
colorAttributePostition |
integer |
Attribute position for color instance attribute used 9× in the base game |
ageAttributePostition |
integer |
Attribute position for age instance attribute used 9× in the base game |
color0AttributePostition |
integer |
Attribute position for the first color of cblend 4 instance attribute |
color1AttributePostition |
integer |
Attribute position for the seconn color of cblend 4 instance attribute |
color2AttributePostition |
integer |
Attribute position for the third color of cblend 4 instance attribute |
color3AttributePostition |
integer |
Attribute position for the fourth color of cblend 4 instance attribute |
Functions
getEntityTime(gameTime : number, entityId : Engine.Entity) : number base/tealdef/scripts/transformator_util.d.tl:81
Call as transformator_util.getEntityTime
Notes
Per-entity time offset: gameTime + entityId, so identical models do not animate in sync.
Returns number
Used in the base game: 9 times in 9 files
base/content/vehicle/ship/shared/shared/transformator_hovercraft.script.tl:32
base/content/vehicle/zeppelin/shared/shared/transformator_zeppelin.script.tl:13
base/content/vehicle/shared/shared/transformator_road.script.tl:9
base/content/vehicle/shared/shared/transformator_air.script.tl:9
base/content/vehicle/tram/shared/shared/transformator_tram.script.tl:9
base/content/vehicle/train/shared/shared/transformator_train.script.tl:9
… and 3 more files.
stableRandomColor(entityId : Engine.Entity) : Vec3f base/tealdef/scripts/transformator_util.d.tl:83
Call as transformator_util.stableRandomColor
Notes
Pseudo-random colour derived from the entity id; the same entity always gets the same colour.
Returns Vec3f
scaleUserTransfIndicesLoadConfig(indicesLoadConfig : {integer}, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:85
Call as transformator_util.scaleUserTransfIndicesLoadConfig
Notes
Hides the model parts with the given user-transform indices by scaling them to zero.
| Parameter | Type | Description |
|---|---|---|
indicesLoadConfig |
{integer} |
Indices of the parts to hide (the vehicle's indicesLoadConfig); nil does nothing. |
transfsOutput |
Transformator.TransfOutput |
Used in the base game: 8 times in 8 files
base/content/vehicle/ship/shared/shared/transformator_hovercraft.script.tl:60
base/content/vehicle/ship/shared/shared/transformator_ship.script.tl:35
base/content/vehicle/shared/shared/transformator_road.script.tl:40
base/content/vehicle/shared/shared/transformator_air.script.tl:82
base/content/vehicle/tram/shared/shared/transformator_tram.script.tl:58
base/content/vehicle/train/shared/shared/transformator_train.script.tl:45
… and 2 more files.
setWheelUserTransf(modelInfo : Transformator.ModelInfo, wheelRotation : number, totalDist : number, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:90
Call as transformator_util.setWheelUserTransf
Notes
Sets user transforms that rotate the wheels by the distance driven and steer them by wheelRotation.
| Parameter | Type | Description |
|---|---|---|
modelInfo |
Transformator.ModelInfo |
Wheel, steering part and wheel sign info of the model. |
wheelRotation |
number |
Steering angle in radians. |
totalDist |
number |
Total distance driven, in metres. |
transfsOutput |
Transformator.TransfOutput |
addDoorAnimationState(doorAnimationInfo : Transformator.DoorAnimationInfo, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:96
Call as transformator_util.addDoorAnimationState
Notes
Adds the door animation described by doorAnimationInfo (name, door time, duration); nil does nothing.
Used in the base game: 8 times in 8 files
base/content/vehicle/ship/shared/shared/transformator_hovercraft.script.tl:17
base/content/vehicle/ship/shared/shared/transformator_ship.script.tl:17
base/content/vehicle/shared/shared/transformator_road.script.tl:20
base/content/vehicle/shared/shared/transformator_air.script.tl:39
base/content/vehicle/tram/shared/shared/transformator_tram.script.tl:26
base/content/vehicle/train/shared/shared/transformator_train.script.tl:34
… and 2 more files.
addBrakeLightsAnimationState(brakingTimer : number, time : number, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:100
Call as transformator_util.addBrakeLightsAnimationState
Notes
Plays brake_lights_on while brakingTimer is positive, otherwise brake_lights_off.
Used in the base game: 4 times in 4 files
base/content/vehicle/shared/shared/transformator_road.script.tl:25
base/content/vehicle/tram/shared/shared/transformator_tram.script.tl:31
base/content/vehicle/train/shared/shared/transformator_train.script.tl:39
base/content/vehicle/train/shared/shared/transformator_tiltingTrain.script.tl:39
addAnimationStatesRailVehicles(side : {boolean}, reversed : boolean, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:105
Call as transformator_util.addAnimationStatesRailVehicles
Notes
Sets the on/off animations that depend on the vehicle's position in the train and direction:
front_/back_/inner_/single_ forward_/backward_parts_on|off, forward_parts_*, backward_parts_*,
has_previous_*, has_no_previous_*, has_next_* and has_no_next_*.
| Parameter | Type | Description |
|---|---|---|
side |
{boolean} |
{isFront, isBack}: whether the vehicle is at the front and/or back end of the train. |
reversed |
boolean |
True if the vehicle is driving backwards. |
transfsOutput |
Transformator.TransfOutput |
Used in the base game: 3 times in 3 files
base/content/vehicle/tram/shared/shared/transformator_tram.script.tl:14
base/content/vehicle/train/shared/shared/transformator_train.script.tl:14
base/content/vehicle/train/shared/shared/transformator_tiltingTrain.script.tl:14
addDriveAnimationState(totalDist : number, reversed : boolean, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:110
Call as transformator_util.addDriveAnimationState
Notes
Adds the looping drive animation driven by distance (1 metre = 1000 animation units).
Used in the base game: 6 times in 6 files
base/content/vehicle/ship/shared/shared/transformator_hovercraft.script.tl:10
base/content/vehicle/ship/shared/shared/transformator_ship.script.tl:10
base/content/vehicle/shared/shared/transformator_road.script.tl:14
base/content/vehicle/tram/shared/shared/transformator_tram.script.tl:20
base/content/vehicle/train/shared/shared/transformator_train.script.tl:20
base/content/vehicle/train/shared/shared/transformator_tiltingTrain.script.tl:20
addBlinkLightsAnimationState(turnLeft : boolean, turnRight : boolean, reversed : boolean, leftStationSince : number, time : number, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:115
Call as transformator_util.addBlinkLightsAnimationState
Notes
Turn-signal animations blink_lights_left_on/off and blink_lights_right_on/off (swapped when
reversed); the left signal also blinks for 5 time units after leaving a station.
addPantographAnimationState(landVehicleApi : Transformator.LandVehicleScriptingApi, pantographMin : number, pantographMax : number, pantographOffsetFromCenter : number, reversed : boolean, distance : number, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:124
Call as transformator_util.addPantographAnimationState
Notes
Sets the pantograph animation frame from the average catenary height around the pantograph position.
| Parameter | Type | Description |
|---|---|---|
landVehicleApi |
Transformator.LandVehicleScriptingApi |
Path query API of the vehicle. |
pantographMin |
number |
Catenary height for the first frame. |
pantographMax |
number |
Catenary height for the last frame. |
pantographOffsetFromCenter |
number |
Pantograph position from the vehicle centre in driving direction, in metres. |
reversed |
boolean |
True if the vehicle is driving backwards. |
distance |
number |
Half-length of the sampled stretch (applied in both directions), in metres; the tram transformator uses 15. |
transfsOutput |
Transformator.TransfOutput |
addDrivingWheelAnimationState(drivingWheelRadius : number, totalDist : number, wheelDuration : number, reversed : boolean, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:134
Call as transformator_util.addDrivingWheelAnimationState
Notes
Adds the looping wheels animation for driving wheels (steam locomotives), synchronised to the distance driven.
| Parameter | Type | Description |
|---|---|---|
drivingWheelRadius |
number |
Radius of the driving wheel in metres; nothing happens if 0 or less. |
totalDist |
number |
Total distance driven in metres. |
wheelDuration |
number |
Length of one wheel turn in the animation. |
reversed |
boolean |
|
transfsOutput |
Transformator.TransfOutput |
addPaddleAnimationState(paddlePhase : number, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:142
Call as transformator_util.addPaddleAnimationState
Notes
Adds the looping paddles animation of paddle steamers from the paddle phase (radians).
addRudderAnimationState(rudderAngleZ : number, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:146
Call as transformator_util.addRudderAnimationState
Notes
Sets the rudder animation from the rudder angle (radians; 0 is the middle frame).
addHelicopterAnimationState(pitchDyn : number, velocityX : number, touchesGround : boolean, bodyAngle : number, vtol : boolean, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:151
Call as transformator_util.addHelicopterAnimationState
Notes
Sets the rotor pitch animation and tilts the body (user transform 1) by bodyAngle.
addPitchAnimationState(velocity : Vec2f, topSpeed : number, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:159
Call as transformator_util.addPitchAnimationState
Notes
Sets the pitch animation from the current speed relative to 75 % of the top speed.
Used in the base game: 2 times in 2 files
base/content/vehicle/shared/shared/transformator_air.script.tl:24
dlcs/urbangames_deluxe_upgrade_pack/content/vehicle/vehicle/plane/concorde/transformator_concorde.script.tl:14
addFlapsAnimation(flapsDuration : number, flaps : number, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:164
Call as transformator_util.addFlapsAnimation
Notes
Sets the flaps animation position from the flap setting.
addGearAnimation(gear : boolean, gearTime : number, gearDuration : number, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:169
Call as transformator_util.addGearAnimation
Notes
Plays open_wheels or close_wheels for the landing gear.
addAircraftControlSurfacesAnimation(aileronLeft : number, elevator : number, roll : number, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:175
Call as transformator_util.addAircraftControlSurfacesAnimation
Notes
Sets the aileron_left, aileron_right, elevator and rudder animations from the control angles (radians).
Used in the base game: 3 times in 3 files
base/content/vehicle/zeppelin/shared/shared/transformator_zeppelin.script.tl:57
base/content/vehicle/shared/shared/transformator_air.script.tl:51
dlcs/urbangames_deluxe_upgrade_pack/content/vehicle/vehicle/plane/concorde/transformator_concorde.script.tl:38
addAircraftLightsAnimation(gear : boolean, gearTime : number, gameTime : number, time : number, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:181
Call as transformator_util.addAircraftLightsAnimation
Notes
Plays beacon_lights and strobe_lights and switches landing_light_on/off with the gear.
Used in the base game: 3 times in 3 files
base/content/vehicle/zeppelin/shared/shared/transformator_zeppelin.script.tl:45
base/content/vehicle/shared/shared/transformator_air.script.tl:58
dlcs/urbangames_deluxe_upgrade_pack/content/vehicle/vehicle/plane/concorde/transformator_concorde.script.tl:45
addBlurredPropsAnimation(propPhase : number, hasPropsBlurred : boolean, thrust : number, maxThrust : number, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:188
Call as transformator_util.addBlurredPropsAnimation
Notes
Switches between props_on and props_blurred_on (and the matching _off states) depending on thrust;
blurred props are used above 5 % of maximum thrust if the model has them.
Used in the base game: 3 times in 3 files
base/content/vehicle/ship/shared/shared/transformator_hovercraft.script.tl:49
base/content/vehicle/zeppelin/shared/shared/transformator_zeppelin.script.tl:36
base/content/vehicle/shared/shared/transformator_air.script.tl:66
addAircraftWheelTransformation(modelInfo : Transformator.ModelInfo, touchesGround : boolean, totalDist : number, wheelAngleZ : number, transfsOutput : Transformator.TransfOutput) base/tealdef/scripts/transformator_util.d.tl:195
Call as transformator_util.addAircraftWheelTransformation
Notes
While on the ground, rotates axles and wheels by the distance driven and steers the steering parts.
Used in the base game: 2 times in 2 files
base/content/vehicle/shared/shared/transformator_air.script.tl:74
dlcs/urbangames_deluxe_upgrade_pack/content/vehicle/vehicle/plane/concorde/transformator_concorde.script.tl:53
calculateTilt(landVehicleApi : Transformator.LandVehicleScriptingApi, speed : number, distance : number, trainReversed : boolean) : number base/tealdef/scripts/transformator_util.d.tl:203
Call as transformator_util.calculateTilt
Notes
Tilt value for tilting trains, from speed and the average track curvature around the vehicle.
| Parameter | Type | Description |
|---|---|---|
landVehicleApi |
Transformator.LandVehicleScriptingApi |
Path query API of the vehicle. |
speed |
number |
Current speed. |
distance |
number |
Half-length of the sampled stretch (applied in both directions), in metres. |
trainReversed |
boolean |
True if the train is driving backwards. |
Returns number: Value between 0 and 1; 0.5 means no tilt.