Transport Fever 2

Transport Fever 2

Real Capacity
MrCheesecake 23. dec. 2024 kl. 19:27
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.
< >
Viser 1-12 af 12 kommentarer
Ganliard  [udvikler] 24. dec. 2024 kl. 4:23 
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 24. dec. 2024 kl. 13:47 
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 26. dec. 2024 kl. 4:41 
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 28. dec. 2024 kl. 0:47 
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.
Sidst redigeret af Don Dirkus; 28. dec. 2024 kl. 0:52
Vuyfield 30. dec. 2024 kl. 10:43 
Can confirm I have the same issue as the others
Ganliard  [udvikler] 31. dec. 2024 kl. 4:27 
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 31. dec. 2024 kl. 6:11 
I assume the fix was to define the variable even when the slider was never touched?
Ganliard  [udvikler] 31. dec. 2024 kl. 6:16 
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

Oprindeligt skrevet af GordonDry:
I assume the fix was to define the variable even when the slider was never touched?
MrCheesecake 1. jan. kl. 17:20 
Thanks for the fix.
Doracmon 8. jan. kl. 5:49 
loads of MODs crashed, please inform me where to add these two lines.(May need some screenshots)
Doracmon 8. jan. kl. 5:54 
or would you please update a version without slider?(the version before Dec)
Ganliard  [udvikler] 10. jan. kl. 11:24 
If you can give me the error message, I can update the mod with the fix
< >
Viser 1-12 af 12 kommentarer
Per side: 1530 50