Transport Fever 2

Transport Fever 2

Create your own game world!
Give your game a personal touch and change it to your liking. Create, share and install mods. Customize the game with new landscapes, vehicles, stations, assets and more.
RadiKyle 6 7 Jul, 2024 @ 1:39pm
script addModifier help needed
Hey folks, I'm trying to use an addModifier for the "loadScript" category (in a mod's runFn). It's triggering okay but when it gets into the modifier function, this statement is failing:

if string.find( fileName, "modules/trainstationutil.lua" ) then

I've tried several alternate conditions such as shorter match string, string.lower instead of string.find, etc, and none return true. The script file exists ofc, at res/scripts/modules/trainstationutil.lua.

Am I misunderstanding what type of files are included in the loadScript category? (I also tried loadGameScript instead.) Is trainstationutil.lua not a script file that loadScript can retrieve?

Thanks!
Last edited by RadiKyle; 7 Jul, 2024 @ 1:39pm
< >
Showing 1-3 of 3 comments
RadiKyle 6 7 Jul, 2024 @ 5:24pm 
...It works for "trackmodule.script". I guess some scripts aren't accessible to the loadScript addModifier 🤷‍♂️ Probably not anything in the game's res/scripts folder.
lollus 15 10 Jul, 2024 @ 7:46am 
That's a *.lua file and not a *.script file, so the modifier won't pick it.
What do you want to do? If you want to override some function, take a look at the Town Tuning where I override some function for building eras. It might work for you as well.
RadiKyle 6 10 Jul, 2024 @ 8:26am 
Thanks @lollus , I'll check it out. Yes my confusion is partly from the modding wiki stating that "scripts" are .lua files (which is certainly true). But there is no detailed description of what is included/excluded with the different addModifier categories. So it seems like we always have to guess / experiment to find out 😖

Yes I'm overriding some functions in certain cases. So far I have been using a "wrapper" method, and it works okay. But recently I found another mod using a custom "package modifier", and I thought it might be a better way. But it seems it only partly works (it's code for a very early version of the game, so maybe out-of-date for current code base). So it gave me the idea to try the addModifiers instead because they seem to have similar intent..., but as you mentioned, I learned that it does not work on the .lua files.
< >
Showing 1-3 of 3 comments
Per page: 1530 50