[Done] Detect other mods installed
[Done] Detect other mods installed
What is the best/correct way to detect if another mod is also being used?
For both Control.lua and Data.lua please.
Thanks.
For both Control.lua and Data.lua please.
Thanks.
Last edited by TheSAguy on Fri May 11, 2018 8:18 pm, edited 3 times in total.
Re: Detect other mods installed
I think it's possible only with reading some items/ entities, if it exists then installed.
-
- Long Handed Inserter
- Posts: 88
- Joined: Fri Apr 22, 2016 9:55 pm
- Contact:
Re: Detect other mods installed
It's actually pretty easy. From http://lua-api.factorio.com/latest/Data-Lifecycle.html:
will tell you if a mod named modname exists.
In the control stage, you have access to http://lua-api.factorio.com/latest/LuaG ... ctive_mods instead, so
will do it.
The settings stage wrote:a global table mods exists that contains a mapping of mod name to mod version for all enabled mods
So, in the data stage,The data stage wrote:The global table mods still exists
Code: Select all
if mods[modname] then
In the control stage, you have access to http://lua-api.factorio.com/latest/LuaG ... ctive_mods instead, so
Code: Select all
if game.active_mods[modname] then
Re: Detect other mods installed
The control stage does not seem to work for me.Exasperation wrote:It's actually pretty easy. From http://lua-api.factorio.com/latest/Data-Lifecycle.html:The settings stage wrote:a global table mods exists that contains a mapping of mod name to mod version for all enabled modsSo, in the data stage,The data stage wrote:The global table mods still existswill tell you if a mod named modname exists.Code: Select all
if mods[modname] then
In the control stage, you have access to http://lua-api.factorio.com/latest/LuaG ... ctive_mods instead, sowill do it.Code: Select all
if game.active_mods[modname] then
I tried the following two:
Code: Select all
if game.active_mods[EndgameCombat] then
game.surfaces[1].print("You have Endgame Combat Installed, not compatable with Natural Evolution Buildings")
end
Code: Select all
for name, version in pairs(game.active_mods) do
game.surfaces[1].print(name .. " version " .. version)
end
Anyone see what I'm doing wrong here?
Control attached.
Thanks.
- Attachments
-
- control.lua
- (34.49 KiB) Downloaded 150 times
Re: Detect other mods installed
EndgameCombat is link, "EndgameCombat" is wordTheSAguy wrote:Code: Select all
if game.active_mods[EndgameCombat] then game.surfaces[1].print("You have Endgame Combat Installed, not compatable with Natural Evolution Buildings") end
Code: Select all
if game.active_mods["EndgameCombat"] then
game.surfaces[1].print("You have Endgame Combat Installed, not compatable with Natural Evolution Buildings")
end
Re: Detect other mods installed
And it won't print anyways in on_init if you are creating a new world.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: Detect other mods installed
I'm not sure what's going on here, I'm can't seem to even display a message without any condition.
The below by itself is not displaying me anything...
The below by itself is not displaying me anything...
Code: Select all
game.surfaces[1].print("You have Endgame Combat Installed, not compatible with Natural Evolution Buildings")
Re: Detect other mods installed
Are you creating a new world with the mod? Then print won't work in on_init because it happens before players are created. Source: NexelaTheSAguy wrote:I'm not sure what's going on here, I'm can't seem to even display a message without any condition.
The below by itself is not displaying me anything...Code: Select all
game.surfaces[1].print("You have Endgame Combat Installed, not compatible with Natural Evolution Buildings")
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: Detect other mods installed
I placed my code in both On-Init and on-Change, but I'm not getting any message displayed.
Re: Detect other mods installed
Players, not surfaces:TheSAguy wrote:I'm not sure what's going on here, I'm can't seem to even display a message without any condition.
The below by itself is not displaying me anything...Code: Select all
game.surfaces[1].print("You have Endgame Combat Installed, not compatible with Natural Evolution Buildings")
Code: Select all
/c game.players[1].print("You have Endgame Combat Installed, not compatible with Natural Evolution Buildings")
Re: Detect other mods installed
UGH, I knew it was user error, I just could not find it!
Thanks.
Thanks.
-
- Manual Inserter
- Posts: 3
- Joined: Fri Sep 15, 2017 10:16 pm
- Contact:
Re: [Resolved] Detect other mods installed
I'd been trying to figure this out for the last couple days... thanks for this thread!
Re: Detect other mods installed
How can I determine if a mod is installed during control.lua, but not during "script.on_configuration_changed" or "script.on_init".
There I can use:
I need to determined if Alien Biomes is running, and if running it should use a different table. I cant use "game" though during normal control as in below
Thanks.
There I can use:
Code: Select all
game.active_mods["mod name"] then
Code: Select all
if game.active_mods["alien-biomes"] then
terrains = require("libs/trees-and-terrains_alien_boimes")
else
terrains = require("libs/trees-and-terrains")
end
Re: Detect other mods installed
I've been using the active-mods method in control.lua without problems.
I don't think it's limited to those events - I have a use from remote interface and it seems to work.
You are trying to make conditional require statements in that if - maybe thats whats not working properly?
I don't think it's limited to those events - I have a use from remote interface and it seems to work.
You are trying to make conditional require statements in that if - maybe thats whats not working properly?
-
- Manual Inserter
- Posts: 1
- Joined: Wed Jul 31, 2019 8:04 am
- Contact:
Re: Detect other mods installed
Its late but the correct code isExasperation wrote: Mon Aug 21, 2017 5:57 am
In the control stage, you have access to http://lua-api.factorio.com/latest/LuaG ... ctive_mods instead, sowill do it.Code: Select all
if game.active_mods[modname] then
Code: Select all
if type(game.active_mods["modname"]) then
Re: Detect other mods installed
That's just extra work to get the same results. You don't need the type check.lukavminaev wrote: Mon Apr 20, 2020 12:20 am Its late but the correct code isCode: Select all
if type(game.active_mods["modname"]) then
If you want to get ahold of me I'm almost always on Discord.