Transport Fever 2

Transport Fever 2

Real Capacity
MrCheesecake 2024 年 12 月 23 日 下午 7: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.
< >
正在显示第 1 - 12 条,共 12 条留言
Ganliard  [开发者] 2024 年 12 月 24 日 上午 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 2024 年 12 月 24 日 下午 1: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 2024 年 12 月 26 日 上午 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 2024 年 12 月 28 日 上午 12: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.
最后由 Don Dirkus 编辑于; 2024 年 12 月 28 日 上午 12:52
Vuyfield 2024 年 12 月 30 日 上午 10:43 
Can confirm I have the same issue as the others
Ganliard  [开发者] 2024 年 12 月 31 日 上午 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 2024 年 12 月 31 日 上午 6:11 
I assume the fix was to define the variable even when the slider was never touched?
Ganliard  [开发者] 2024 年 12 月 31 日 上午 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

引用自 GordonDry
I assume the fix was to define the variable even when the slider was never touched?
MrCheesecake 1 月 1 日 下午 5:20 
Thanks for the fix.
Doracmon 1 月 8 日 上午 5:49 
loads of MODs crashed, please inform me where to add these two lines.(May need some screenshots)
Doracmon 1 月 8 日 上午 5:54 
or would you please update a version without slider?(the version before Dec)
Ganliard  [开发者] 1 月 10 日 上午 11:24 
If you can give me the error message, I can update the mod with the fix
< >
正在显示第 1 - 12 条,共 12 条留言
每页显示数: 1530 50