manual:subwaysim:vehicle_development:vehicle_lua
This is an old revision of the document!
Table of Contents
Creating a Simple Vehicle.lua
This page explains how to create a simple `vehicle.lua` file, primarily intended for AI-controlled trains in SubwaySim 2.
A simple `vehicle.lua` usually defines:
- Vehicle metadata (name, author, IDs)
- Basic physical parameters (mass, length, vmax)
- Blueprint references
- Coupling definitions
- Braking systems
- Basic lights and audio
- Train compositions for AI
For a detailed explanation of a fully featured and player-drivable vehicle, see:
Example Vehicle.lua (AI Vehicle)
The following example is based on the GI1E (Gisela) AI vehicle used in the SubwaySim base game.
Because the original file is not publicly downloadable, the full structure is shown below and explained step by step in separate sections.
- vehicle.lua
---@type RailVehicle_DataTable local GI1E_a = { contentType = "railVehicle", contentName = "Berlin_GI1E_a", title = "GI1E", author = "$GameDeveloper", emptyMass = 37.0, vmax = 70, length = 12.64, frontToFirstBogie = 2.53, rearToLastBogie = 2.53, maxEnginePower = 480, maxEngineForce = 50, blueprintFilename = "/SubwaySim_Berlin/Vehicles/GI1E/BP_GI1E_A.BP_GI1E_A", couplingFront = { rotationOrigin = "Coupling_F", couplingOffset = 0.985, automaticCoupling = true, skeletalMesh = "Exterior", couplingBoneName = "Coupling_Rotation1", }, couplingRear = { rotationOrigin = "Coupling_B", couplingOffset = 0.985, automaticCoupling = true, skeletalMesh = "Exterior", couplingBoneName = "Coupling_Rotation2", }, -- players shouldn't try to attach this vehicle cameras = { exteriorCameras = {}, }, brakingSystems = { pneumatic5bar = { maxBrakeForce = 60, }, electric = { maxBrakeForce = 50, maxBrakePower = 480, }, }, components = { LightManager, VehicleNumber, AudioManager, Berlin_PIS, }, audio = { audioBogieAI = { { audioComponent = "AiAudio", }, }, }, lights = { headLights = { { direction = 1, headlightElements = { { mesh = "Exterior", materialSlot = "GI1E_LightsExterior_mat", materialParams = { ["Emissive01"] = 100, }, lightComponents = { {lightComponent ="Headlight1", intensity = 50, temperature = 4500, attenuationRadius = 500, innerConeAngle = 0, outerConeAngle = 70}, {lightComponent ="Headlight2", intensity = 50, temperature = 4500, attenuationRadius = 500, innerConeAngle = 0, outerConeAngle = 70}, }, }, }, }, }, tailLights = { { mesh = "Exterior", materialSlot = "GI1E_LightsExterior_mat", direction = -1, materialParams = { ["Emissive02"] = 100, }, }, }, }, ---@type Berlin_PIS_DataTable PIS = { destinationDisplays = { { componentName = "ZZA", direction = 1, }, }, announcementNextStop = {}, announcementTerminus = { "/SubwaySim_Berlin/Vehicles/Shared/Audio/Announcements/General_Termination01.General_Termination01", }, announcementExitLeft = {}, announcementExitRight = { "/SubwaySim_Berlin/Vehicles/Shared/Audio/Announcements/General_ExitRight.General_ExitRight", }, announcementBell = { "/SubwaySim_Berlin/Vehicles/Shared/Audio/Gong/Berlin_Standardgong_MasterV1_kurz.Berlin_Standardgong_MasterV1_kurz", }, announcementTerminusBell = { "/SubwaySim_Berlin/Vehicles/Shared/Audio/Gong/Berlin_Infogong_MasterV2_kurz.Berlin_Infogong_MasterV2_kurz", }, announcementDelay = 1.2, defaultDestinationAnnouncement = "/SubwaySim_Berlin/Vehicles/Shared/Audio/Announcements/Destination_General.Destination_General", destinationAnnouncementByLine = { ["U1"] = "/SubwaySim_Berlin/Vehicles/Shared/Audio/Announcements/Destination_U1.Destination_U1", ["U2"] = "/SubwaySim_Berlin/Vehicles/Shared/Audio/Announcements/Destination_U2.Destination_U2", ["U3"] = "/SubwaySim_Berlin/Vehicles/Shared/Audio/Announcements/Destination_U3.Destination_U3", ["U4"] = "/SubwaySim_Berlin/Vehicles/Shared/Audio/Announcements/Destination_U4.Destination_U4", }, audioComponent = "PIS_Audio", autoTerminateAnnouncement = false, }, vehicleNumber = { labels = { { mesh = "Exterior", materialSlot = "DecalDigits_mat", }, }, poolName = "Berlin_GI1E", poolValueMin = 1070, poolValueMax = 1094, }, }; ---@type RailVehicle_DataTable local GI1E_b = TableUtil.deepCopy(GI1E_a); GI1E_b.components = GI1E_a.components; -- TODO GI1E_b.contentName = "Berlin_GI1E_b"; GI1E_b.blueprintFilename = "/SubwaySim_Berlin/Vehicles/GI1E/BP_GI1E_B.BP_GI1E_B"; GI1E_b.lights.headLights = nil; GI1E_b.lights.tailLights = nil; GI1E_b.couplingFront.couplingBoneName = "Coupling_Rotation3"; GI1E_b.couplingRear.couplingBoneName = "Coupling_Rotation4"; ---@type TrainComposition_DataTable local GI1E_1x = { contentType = "trainComposition", contentName = "Berlin_GI1e_1x", title = "GI1e x1", author = "Simuverse GmbH", -- not required for AI trains description = "", previewFilename = "", hidden = true, vehicles = { { contentName = "Berlin_GI1E_a", forward = true, }, { contentName = "Berlin_GI1E_b", forward = true, }, { contentName = "Berlin_GI1E_b", forward = false, }, { contentName = "Berlin_GI1E_a", forward = false, }, }, }; ---@type TrainComposition_DataTable local GI1E_2x = { contentType = "trainComposition", contentName = "Berlin_GI1e_2x", title = "GI1e x2", author = "Simuverse GmbH", -- not required for AI trains description = "", previewFilename = "", hidden = true, vehicles = { { contentName = "Berlin_GI1E_a", forward = true, }, { contentName = "Berlin_GI1E_b", forward = true, }, { contentName = "Berlin_GI1E_b", forward = false, }, { contentName = "Berlin_GI1E_a", forward = false, }, { contentName = "Berlin_GI1E_a", forward = true, }, { contentName = "Berlin_GI1E_b", forward = true, }, { contentName = "Berlin_GI1E_b", forward = false, }, { contentName = "Berlin_GI1E_a", forward = false, }, }, }; g_contentManager:addContent(GI1E_a); g_contentManager:addContent(GI1E_b); g_contentManager:addContent(GI1E_1x); g_contentManager:addContent(GI1E_2x);
Next Steps
In the following sections, we will break down this file step by step and explain what each part does:
- Metadata and identifiers (`contentType`, `contentName`, `title`, `author`)
- Physical parameters (`emptyMass`, `length`, `vmax`, engine values)
- Blueprint reference (`blueprintFilename`)
- Coupling setup (`couplingFront`, `couplingRear`)
- Braking systems (`brakingSystems`)
- Basic components, lights and audio
- Train compositions (`trainComposition`) for AI
manual/subwaysim/vehicle_development/vehicle_lua.1768286536.txt.gz · Last modified: by dcs
