Transport Fever 2

Transport Fever 2

Freight Yard Framework
RadiKyle Jun 13, 2024 @ 3:06pm
Fix for non-vanilla track types
Heya @[190]Yocto while working on a mod and fixing some compatibility issue with yours, I think I resolved some errors involving non-vanilla track types (some others mention this below). In your yard_station.con you can replace the following section with the code from vanilla modular_station.con:

local cumsum = { 0, #result.edgeLists[1].edges, #result.edgeLists[1].edges+#result.edgeLists[2].edges, #result.edgeLists[1].edges+#result.edgeLists[2].edges+#result.edgeLists[3].edges, }

replace with

local cumsum = {} local c = 0 for x = 1, #result.edgeLists do cumsum[x] = c c = c + #result.edgeLists[x].edges end
(Note, the code actually uses "i" but I put x here because the forum kept treating it as italics code {i} {/i} lol!)

The mod's currently hard-coded for only the 4 vanilla track types (standard, high speed, plus catenary versions), whereas the vanilla modular station code permits unlimited track types. Making this change clears the errors that occur when trying to using non-vanilla tracks with your stations (like those mentioned in comments by others), and it makes your station construction work with my mod. It also makes my life a whole lot easier, as right now I have to basically override your code haha.

Let me know if any questions, I can provide a lot more details on this. Cheers
Last edited by RadiKyle; Jun 13, 2024 @ 3:12pm
< >
Showing 1-4 of 4 comments
[190]Yocto  [developer] Jun 22, 2024 @ 3:51pm 
Thank you! I haven't had any time to maintain this, so I really appreciate it. I'll get that folded in soon.
RadiKyle Jun 22, 2024 @ 4:55pm 
It might actually need more changes than I thought haha 🙈 It seems that change will permit non-vanilla tracks to be added to your station, but the platform modules with the hidden/invisible cargo spawns will show the cargo again. That requires more work...

I've learned that the main thing happening here is that your mod uses the RunFn in mod.lua to do its thing, which is run *before* any track mods are loaded, so it only "sees" the 4 vanilla tracks. The above change makes it accept mod tracks, but it doesn't fully support them. I think the mod would need to be changed to use postRunFn instead, so its running *after* all track mods are loaded.

The challenge there is that several mods are all using that method at the same time and there can be conflicts. In my mod that I just released, I included support for your mod (and Early Cargo Shed) plus some others to avoid breaking things. But making your mod fully capable with track mods would require integrating them somehow I think. I have been thinking about producing a "patch/fix" mod that uses yours as a dependency, makes it fully support track mods, and still works with mine and the others.


I'll keep chipping away at it and if I get some more code that actually works I can send it your way... 🤞
Last edited by RadiKyle; Oct 19, 2024 @ 8:39am
RadiKyle Oct 19, 2024 @ 8:53am 
Hi again, ok pls ignore my prev msg it was mostly wrong lol 🙈 I've learned a lot more since then haha! (I've also completely changed my own mods to remove conflicts.)

Your mod only checks for tracks with .module files ("static track types"). It doesn't check for tracks created by trackmodule.script ("dynamically created track types"), which are like 99% of the track mods. So your platforms only works with vanilla tracks and a tiny number of mod tracks.

Then your custom yard_station.con file has some out-of-date code from early versions of the game that prevents it from working with other track types, and also breaks the pooled storage capacity.

I updated the mod, .zip file available here:
https://drive.google.com/file/d/1-Ssyyclt6Lr2C8G-NYFD2kDo5b_1t8Qa/view?usp=sharing

Changes:
mod.lua - see comments inside it
yardstationutil.lua - added "closureParams"
yard_station.con - fixed code for "cumsum" and "pool"
(I left backup copies of the original files, "RKBAK" in the filenames.)

Now your station template works with any track type and with pooled storage. And your platforms also work in other modular stations with any track type.

Feel free to review the changes or if you want you can just delete the backup copies and upload the updated version to Steam.

Hope that helps, cheers!
RadiKyle Oct 20, 2024 @ 7:10am 
...I updated the .zip file with a few lines I forgot to included in the yard_station.con related to pooled storage capacity. The mod has shared storage now just like vanilla stations 🥳
< >
Showing 1-4 of 4 comments
Per page: 1530 50