Transport Fever 2

Transport Fever 2

Not enough ratings
Making Your Vehicles into Assets
By themeatballhero
As an asset for your vehicle mod. Included is also a way to make them random in placement, great for freight cars & other rolling stick.
   
Award
Favorite
Favorited
Unfavorite
Introduction
I was playing through recently and noticed a surprising amount of lack of vehicle assets. Its a pretty small process so will make an awesome addition for aesthetics in your own save!
Prepping your Files
This step is easy. First, copy your vehicle mdl's in your explorer.

Depending on your file structure, I always advise making a separate folder structure for assets.

Lets say for instance, the folder structure is as below:

/models/model/vehicle/train/tmbh(my initials)/up_big_boy/4014.mdl

I would make a new folder as below:
/models/model/asset/train/tmbh/up_big_boy/4014_asset.mdl

So make your new mdl's and add "_asset" at end of the mdl file name. This isn't needed but will make your life easier in editing the files. In the new asset files, remove any reference to emissives/lights (unless you prefer the lights lit up in your assets). Removing the metadata ensures it won't show up in the buy menu.

Afterwards, under /res, make a folder with the following path:
res/construction/tmbh/gondola_52_6/gondola_52_6.con
Replace "tmbh" with your own name and "gondola_52_6" with your mods name. This makes it easier to identify file issues and what mod is causing it, mainly with mod compatibility issues.

Tip:
I personally use a second-party file explorer named FreeCommander. Great program, includes the options to make favorites, pin files and has tab options. Also uses the legacy right click menu, for you Windows 11 users that hate the new right click menu. You can also set the scheme of your UI as well to different colors.

But most importantly for this tutorial, includes the option to rename multiple files at once, particularly helpful in making your asset mdls.


To download, check the comments for the link or Google "FreeCommander File Explorer"
The .Con File
Okay, now that the asset .mdl's are created, next is to make up the construction file. See the code below I took from my 52-6" Gondola. You can copy the whole thing for your own mod.

Anything with
--
preceding the text is a comment and won't affect the code.

local locomotiveFiles = { "vehicle/waggon/usa/tmbh/52-6_gondola/atsf.mdl", "vehicle/waggon/usa/tmbh/52-6_gondola/bethlehem.mdl", "vehicle/waggon/usa/tmbh/52-6_gondola/erie.mdl", } --above are the file references local locomotiveNames = { "ATSF", "Bethlehem Steel", "Erie", } --above are the names to be displayed. function data() return { type = "ASSET_TRACK", description = { name = _("52-6 Gondola"), description = _("52-6 Gondola Track Assets"), icon = "[texture file path]" --i usually use the group mdl buy menu icon under /ui/models_small/ }, availability = { yearFrom = 1950, }, buildMode = "MULTI", categories = { "themeatballhero" }, order = 2713,--no idea what this does skipCollision = true, autoRemovable = false, params = { { key = "skin", name = _("Gondola Selection"), values = locomotiveNames, defaultIndex = 0, uiType = 'COMBOBOX', }, }, updateFn = function(params) local result = {} result.models = {}--results.model is declared result.groundFaces = {} result.terrainAlignmentLists = {} local p = params.skin + 1 result.models[#result.models+1] = { id = locomotiveFiles[params.skin], transf = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 } } --it is declared again here, overwriting what was previously declared local groundFace = { { .1, 0,0 },{ .1, .1,0 },{ 0, .1,0 },{ 0, 0,0 } } result.groundFaces[#result.groundFaces + 1] = { face = groundFace, modes = { { type = "STROKE_OUTER", key = "building_paving.lua" } } } result.terrainAlignmentLists = { {type = "EQUAL",faces = {groundFace},slopeLow = 0.3,slopeHigh = 0.6,optional = true,} } return result end } end
Randomized .Con's
If you're making rolling stock, you may be interested in making randomized assets. Here's the code below.

Anything with
--
preceding the text is a comment and won't affect the code.

local locomotiveFiles = { "vehicle/waggon/usa/tmbh/52-6_gondola/atsf.mdl", "vehicle/waggon/usa/tmbh/52-6_gondola/bethlehem.mdl", "vehicle/waggon/usa/tmbh/52-6_gondola/erie.mdl", } --above are the file references local locomotiveNames = { "Random", "ATSF", "Bethlehem Steel", "Erie", } --above are the names to be displayed. take note that "Random" is the first entry. locomotiveNames should always be one entry longer than locomotiveFiles, and after "Random" the file names should match the order of locomotiveFiles. function data() return { type = "ASSET_TRACK", description = { name = _("52-6 Gondola"), description = _("52-6 Gondola Track Assets"), icon = "[texture file path]" --i usually use the group mdl buy menu icon under /ui/models_small/ }, availability = { yearFrom = 1950, }, buildMode = "MULTI", categories = { "themeatballhero" }, order = 2713, skipCollision = true, autoRemovable = false, params = { { key = "skin", name = _("Gondola Selection"), values = locomotiveNames, defaultIndex = 0, uiType = 'COMBOBOX', }, }, updateFn = function(params) math.randomseed(os.time()) --this is what guarantees the randomness of the assets. does a new seed (order of skins chosen) every new second based on OS time. local result = {} result.models = {} result.groundFaces = {} result.terrainAlignmentLists = {} local p = params.skin + 1 if params.skin == 0 then --if the selection is random then the random generator begins local k = math.random(1,#locomotiveFiles) local randomCar = locomotiveFiles[k] --assigns the model chosen by math.random to be selected result.models[#result.models+1] = { id = randomCar, transf = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 } } else result.models[#result.models+1] = { id = locomotiveFiles[params.skin], transf = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 } } end local groundFace = { { .1, 0,0 },{ .1, .1,0 },{ 0, .1,0 },{ 0, 0,0 } } result.groundFaces[#result.groundFaces + 1] = { face = groundFace, modes = { { type = "STROKE_OUTER", key = "building_paving.lua" } } } result.terrainAlignmentLists = { {type = "EQUAL",faces = {groundFace},slopeLow = 0.3,slopeHigh = 0.6,optional = true,} } return result end } end
TL;DR
Create the asset mdls, copy the code from either first bit or the second bit if you want randomized vehicle assets, replace the mdl references and change the names, and you're golden ponyboy.
1 Comments
themeatballhero  [author] Oct 14, 2024 @ 1:36pm 
Here is the link for FreeCommander:
https://freecommander.com/en/summary/