Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
So instead I had to completely redo my .mtl definitions to be compatible with this particular mod that renders things incorrectly, because I have to assume that it's active.
Both are already in the Workshop now.
Hi @Doug , yeah that's the one. It's all .fs scripts. Its mod.lua does set a shader flag, but it seems it's legacy as it's not an available parameter in the game. (And in any case wouldn't tell me *which* shader mod is loaded if there were more than one.)
However, it is detectable in the resource modifier functions, so...
Make a copy of one of the stock vehicle model files.
Rename it to menu_shader_signal.mdl, or some such. Just include the "menu" so that my Unlock Multiple Units mod will leave it alone.
Set the availability dates to yearFrom = 1 and yearTo = 2, so that it doesn't ever show up in the purchase menu.
Now, add a model resource modifier to your mod. Use it to check for your model file.
When that model file comes through the modifier, set
data.metadata.transportVehicles.multipleUnitOnly to the value of game.config.shaderMod
In postRunFn, you can pull that model file from the model repository and check the value of the multipleUnitOnly flag. You will now know whether the shader mod is loaded.
I need to check the wiki to learn about "resource modifiers"...
https://transportfever2.com/wiki/api-testing/topics/states.md.html
They don't talk to each other much - not at all really, so you need to work around this issue, hence the hijacking of a convenient boolean variable in a dummy model file.
So yes, context is the issue.
Once the various models have been loaded into the repository, all of the non-canonical information that might have been included in the metadata has been removed, so you can't just make up some random metadata key to move information like this into the postRunFn.
There is a sample modifier function in the wiki. It checks the metadata for (I think) steam locomotives.
You will be checking the fileName parameter for the name of your model file.
You will be using string.find - have a look at Early Start. It does some of that.
Is the runFn basically a queue where all the mods commands are submitted, then they're all run collectively as a batch, values can be shared/influence each other, and only the results of all that is available in the resource tables via posRunFn? How does it ensure that their flag is set before my resource modifier checks it?
Maybe I'm just asking stuff I don't need to know, just trying to understand it.
Edit: whups simul-post, just reading your reply now...
How it processes the all the parallelized runFns to ensure that their flag has actually been set before mine wants to read it is still confusion for me..., it sounds like it's a recursive process.
This is where the modifier functions are set up, but not where they actually run.
So, in the case at hand, that flag - game.config.shaderMod, has been set before any of the modifier functions have actually been called.
Now, all the resources are loaded, and handed to the resource modifiers, again, in the order those modifiers were themselves loaded. Once all those functions have been called, and the related modifications made, the modified files are loaded into the repositories, for use in postRunFn and the scripting API,
The function 'data' that you see in the model file is the same 'data' that is being passed in to the modifier function. Anything in the model file can be accessed in the model modifier function.
Ok so I built a test and got the flag info carried thru. However it didn't show up quite where I hoped it would be...
I had to choose which api.res table to poll in the postRunFn, so I chose the multipleUnitRep since we're playing with that element and that table is likely infinitely shorter to search than the insane modelRep table. But even tho the MU flag got set (because shader mod is loaded too), my fake model didn't appear in the MMU list. So there must be other reqts for a model to land in that table.
So instead I putted around in console and found my fake model as #4033 🙄 of the massive modelRep table (and that's just vanilla with only 2 mods loaded...).
As I've been learning all this modding stuff and seeing all these workarounds in postRunFn, I'm seriously wondering just how much of the savegame load time is because of all the costly recursive string if-then checks that mods are running.
I'll give your great idea to select the .mtl files directly in runFn some thought... I think it'll depend on the case. I have one mod that builds a long list of new dynamic resources (railroad crossings) from all loaded mods, so I think I'm stuck with postRunFn for that one. My other one doesn't, but it also checks for the presence of resources created by another mod, so I think I might still be tied to postRunFn for that one too, but I'll give it a check. I feel I might be safer staying in postRunFn tho, because I don't know what all the other mods are doing... (that's actually how I discovered your 1800s unmarked railroad crossing I didn't know was there lol)
I started a new thread on what filenames be safely changed in a mod update, since it's a much broader topic than this one about detecting other mods. But my immediate example is still this same one.
I'm starting to test putting conditional code into the .mtl / .mdl files just to avoid dealing with 2 set of filenames that might break a savegame. It seems to work, but it departs from the "standard" .mtl / .mdl file contents.
The code is simply:
but it won't call the addModifier. (Also tried it with if...== true, but no difference)
I've no idea what I'm doing wrong.
So I can only get the postRunFn method to work instead.
Edit: It also seems there is no way to modify an .mtl file contents, either by addModifier or api.res calls, because Materials are not one of the available categories. So Models/.mdl are as "low" as I can go down the resource tree.