Transport Fever 2

Transport Fever 2

Real Capacity
MrCheesecake Dec 23, 2024 @ 7:27pm
Crashing when running cost and price in MDL aren't automatically set
Hi, I recently received two reports that at least two of my mods are crashing save games, and according to an stdout it's linked to the Real Capacity mod and some eatglobal script.

Error message: error: E:/SteamLibrary/steamapps/workshop/content/1066780/2332214931/mod.lua:205: attempt to perform arithmetic on field 'runningCostScale' (a nil value) stack traceback: =[C](-1): __mul @E:/SteamLibrary/steamapps/workshop/content/1066780/2332214931/mod.lua(205): v @res/scripts/mod.lua(102): origApplyModifiers @E:/SteamLibrary/steamapps/workshop/content/1066780/2152316896/res/scripts/eatglobal/eat_mod.lua(298): ? File name: E:/SteamLibrary/steamapps/workshop/content/1066780/1991666499/res/models/model/vehicle/train/usa/metrolinerAM1.mdl

I'm not sure if your recent update on the 22nd changed anything to cause these new crashes, but I think what is causing the issue is that the price and running cost in my MDLs are not set to -1; I had manually set a value for whatever reason. After changing both of those values to -1, the MDL seemed to no longer crash the game. For now I'll try changing all of them and see how that works, but I thought I'd let you know as well.
< >
Showing 1-12 of 12 comments
Ganliard  [developer] Dec 24, 2024 @ 4:23am 
It seems that you identified the issue correctly, it is my script not covering the case of price not being -1. What values of running cost and price caused the crash?
MrCheesecake Dec 24, 2024 @ 1:47pm 
For price, I had 3500000 and 2000000, running costs are 562500 and 300000. I don't know if it's worth noting, but values of 0 and 1 also crashed the game.
SinergyX Dec 26, 2024 @ 4:41am 
I first tried to disable all mods that would crash on this, but turned out it was a ton of them (yeah.. i got like 800 mods running). From my basic primitive knowlegde, seems like it crashes on mods that have no RunningCostScale set in their .mdl. From the wiki i read:
When runningCost or lifespan is left out, it defaults to 0.

I havent checked every single mod to see if this value was added in the mdl, but it might be a pointer where it goes wrong?
Don Dirkus Dec 28, 2024 @ 12:47am 
Hello, since you added the sliders, I get an error message when loading a map or save game and it freezes.
Please check your MOD again, because it was actually very good.

I have the same problem as MrCheesecake

Please reply.
Last edited by Don Dirkus; Dec 28, 2024 @ 12:52am
Vuyfield Dec 30, 2024 @ 10:43am 
Can confirm I have the same issue as the others
Ganliard  [developer] Dec 31, 2024 @ 4:27am 
The issue with your mod has been fixed. Thank you for the detailed error message, @MrCheesecake, it turns out only a tiny fix was needed.
GordonDry Dec 31, 2024 @ 6:11am 
I assume the fix was to define the variable even when the slider was never touched?
Ganliard  [developer] Dec 31, 2024 @ 6:16am 
I added two lines to the code, which initialise the variables if they haven't been defined in the mdl file:
metadata.maintenance.runningCostScale = metadata.maintenance.runningCostScale or 1
metadata.cost.priceScale = metadata.cost.priceScale or 1

Originally posted by GordonDry:
I assume the fix was to define the variable even when the slider was never touched?
Thanks for the fix.
loads of MODs crashed, please inform me where to add these two lines.(May need some screenshots)
or would you please update a version without slider?(the version before Dec)
Ganliard  [developer] Jan 10 @ 11:24am 
If you can give me the error message, I can update the mod with the fix
< >
Showing 1-12 of 12 comments
Per page: 1530 50