How to check for other mods in 0.13+?

Place to get help with not working mods / modding interface.
User avatar
Versepelles
Long Handed Inserter
Long Handed Inserter
Posts: 70
Joined: Sat May 28, 2016 1:42 pm
Contact:

How to check for other mods in 0.13+?

Post by Versepelles »

I'm trying to check to see if the user has some mods loaded, and I would prefer to do this in a config file, but I'm not sure the new way to do this is 0.13.

Specifically, I'm trying to check for a mod like Natural Convergence to add it's entities to a list for which I generate other items that spawn those entities. The check should probably occur in "config" which is then loaded by "entities" in the prototypes folder which is, in turn, loaded by the standard "data".

How does one check for specific mods installed? I see game.active_mods, but "game" is nil at the time of loading for "data.lua".
User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 254
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: How to check for other mods in 0.13+?

Post by DedlySpyder »

You'll have to check to see if one if its entities exist (make it an optional dependency). That was the old way atleast, IIRC, so I assume it'll still work
patmo98
Inserter
Inserter
Posts: 27
Joined: Sat Mar 21, 2015 10:59 pm
Contact:

Re: How to check for other mods in 0.13+?

Post by patmo98 »

DedlySpyder wrote:You'll have to check to see if one if its entities exist (make it an optional dependency). That was the old way atleast, IIRC, so I assume it'll still work
I think you also need a soft dependency on that other mod, to make sure it loads before yours. Then you can just look to see if the thing you want to add support for exists, rather than checking if the mod is loaded.
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2179
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: How to check for other mods in 0.13+?

Post by Ranakastrasz »

Added LuaGameScript::active_mods - a table of active mod names to mod versions.
Presumably this has something to do with it.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 254
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: How to check for other mods in 0.13+?

Post by DedlySpyder »

Ranakastrasz wrote:
Added LuaGameScript::active_mods - a table of active mod names to mod versions.
Presumably this has something to do with it.
You can't access game during the data loading phase though
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2179
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: How to check for other mods in 0.13+?

Post by Ranakastrasz »

Wut?
....

What is the point of adding that?
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 254
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: How to check for other mods in 0.13+?

Post by DedlySpyder »

Ranakastrasz wrote:Wut?
....

What is the point of adding that?
So that you can check on_init. I have a mod that has arrays of entities, so I can check active mods after the game starts to correct any values in the arrays. Link
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2179
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: How to check for other mods in 0.13+?

Post by Ranakastrasz »

I should say, why is it not set on program load instead? You can't change it without restarting, and it would fix the ridiculous mod checking method we use now...
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 254
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: How to check for other mods in 0.13+?

Post by DedlySpyder »

Ranakastrasz wrote:I should say, why is it not set on program load instead? You can't change it without restarting, and it would fix the ridiculous mod checking method we use now...
Why does active_mods not set on program load? I can't say for sure, I guess it's a matter of how would you access it otherwise? Data.raw only contains information for prototypes AFAIK, so they'd have to expand it to allow us to check it I guess.
Post Reply

Return to “Modding help”