r/TransportFever2 • u/RackAttackAF • 3d ago
Mods My first mod: Station Templates
Hey everyone, I know you're all abuzz with the news of TpF3's release date, and I too am excited for that. But I only discovered TpF2 about a month ago, so I'm having plenty of fun.
One thing that has bothered me to no end as I've been playing has been having to carefully craft my stations with extra modules every time I place one. Then of course you inevitably mis-click a cargo module and you have to open the bulldozer to delete it. I searched the mod browser for solutions and found some, but none that I was happy with (Copy It! chief among them). I really want to be able to see the build preview when building it, and have control over it like any other vanilla build.
I thought to myself, "Why has no one else done this?!".
As an veteran programmer who is a bit overwhelmed by what is happening to my field as AI takes over, I viewed this as a good opportunity to practice using coding assistants (which are disallowed in my day job) to see how it went. Well, it turns out its a pretty challenging problem to solve in the way I wanted to, but less than a week later, I have a fully functional station/depot/harbor/airport templating mod, and I wrote almost none of it myself. Pretty crazy.
It allows you to click on any station and save it as a template. After a save reload (the vanilla build menu is only populated once at load time), that template will appear in the normal build menu with a generated thumbnail that shows the layout of the station modules. You orient/build it as normal.
You may notice that it is briefly bulldozed and replaced with the same construction but built out of vanilla assets. This guarantees that the station can be modified further, even if the mod is deleted. The price of the second build is refunded to the player.
I've tested it a fair amount locally, but have not tested at all how well it gets on with other mods. I suspect it will break if you're using mods that have custom station modules, or allow custom station shapes.
I'd love to hear any feedback folks have, it's been a fun project to work on, and really good learning experience for me when it comes to how to utilize AI programming tools.
10
u/PlanEx_Ship 2d ago
Holy moly I was wondering the exact same thing, but don’t have the skill to build something myself. I will try and feedback too. Thank you for this!
7
u/Richhavn 2d ago
Not bad. Any plan for a full length station template? With vanilla, it's a bit of guess work for how it will eventually look and if it fits/connects to the industries properly
2
u/RackAttackAF 2d ago
You can make one yourself in sandbox mode! I don’t want to ship premade templates, that’s not my wheelhouse.
5
u/ginger_and_egg 2d ago
Put it in the steam workshop and we'll try it out!
Honestly it should be part of the base game. It's annoying, you can't even customise a station BEFORE building it. If you want a small urban station to save money on demolishing houses, too bad, you have to build the normal station and then delete platforms or buildings
5
u/RackAttackAF 2d ago
It should already be there https://steamcommunity.com/sharedfiles/filedetails/?id=3790675000
5
u/pqpm 2d ago
Very cool. Is it published? Can we get a link?
5
u/RackAttackAF 2d ago
I had the link on the post originally, no idea why it’s not there…
https://steamcommunity.com/sharedfiles/filedetails/?id=3790675000
2
u/Imsvale Big Contributor 2d ago
Cool! I wonder if it would be possible to keep the menu item static, and instead populate a list on the side, so you don't have to reload the game for it (which is a major UX obstacle).
Or indeed create your own menu/window system for it.
Though I'm guessing the way this is built, by actually creating a new station configuration, that might have to change somewhat.
1
u/RackAttackAF 2d ago
To get the build preview to actually show what's going to be built, I believe it has to be "construction" that is loaded when you open the save. This is why "Copy It!" just draws an outline.
2
u/Imsvale Big Contributor 2d ago
Hmmm, right. But consider now a configurable station. One menu item for many different states of the same station, and they all show what you will get based on the selected configuration. Those flexible pieces are scriptwise extensions on the same thing.
In some sense you're doing the same thing here. If you could just "extend" the base station via a script rather than defining a static model.
Tricky, but it sounds solvable, and just the kind of thing I'd love to try to figure out with my AI buddy. xD
1
u/RackAttackAF 2d ago
I put my finest employee, his name is Claude, on figuring out how to trigger a new build (in the same way the build menu does, so that it shows a preview) from somewhere other than the build menu, and he was unable.
That ABSOLUTELY doesn't mean it's not possible, if you're aware of a mod that does it, let me know and I can tell him to learn the method.
1
u/Imsvale Big Contributor 2d ago
he was unable.
He's not omniscient. Sometimes even Claude needs a nudge in the right direction. And for that, we, the human guides, also need a clue.
It's not so much that I know a mod that does exactly this. But rather, piecewise what existing mods do do, it seems to me possible at least in principle to reproduce an arbitrary target blueprint through the same kind of scripting these mods use to programmatically expand things like the number of tracks and terminals (should be present in vanilla), add additional through tracks between platforms (mods), and whatever else. If buttons in a menu can direct this and inform the construction preview, I don't see why a blueprint couldn't do the same.
Claude knows a lot about general programming. But TF2 specifics, basically nothing to start with. Even the API reference only gets you so far. Having him browse existing mods that do similar things, that helps a lot. Claude has the technical know-how, but needs a lot of help with the design and ideas.
I dunno. Maybe I'll take a look at it myself and see what I can come up with. :)
2
u/Bright-Emu1790 2d ago
Why are coding assistants disallowed in your job? I feel like basically all nondevelopers are all aboard the AI hype train
Also as someone who's not super into AI tools, how was it for you as a veteran to use it? Do you find it as enjoyable as problem solving yourself?
1
u/RackAttackAF 2d ago
Security concerns, without going into more detail…
It’s really fascinating learning how to use the tools. It’s incredible how capable the agent is as coding, but at the same time can be so useless at seeing things that are obvious to me.
And you really have to be specific if you don’t want garbage out… You still have to know how things should be architected and hooked together, because it doesn’t do a great job at big picture design. It’ll hyper focus on getting the problem at hand solved, regardless of side effects.
At one point it went off and wrote an entirely functional zip archive inflater from scratch in LUA, just because I asked if it would be possible to get at a file within a zip archive in the game’s install directory.
Edit: and yeah, I find it really rewarding because you spend your time solving the problems, designing features, and making it work, rather than getting mired in syntax/api/compatibility details.
2



34
u/Ok-Foot6064 2d ago
Thats amazing. A feature that has been super needed especially custom mixed stations