I maintain a loader mod, and I'm experimenting and testing the interactions when LoaderRedux is present.
Currently the interactions are favorable, nothing is wonky, except that the control logics from both mods are conflicting. (Specifically, LoaderRedux mod settings are ignored, and I want them to be supported.)
A solution I had thought to do is, when my mod and LoaderRedux are both activated, to defer to the control.lua in LoaderRedux.
I haven't the faintest idea how to do this, assuming this is even possible. There may be a better way to do this, but rewriting control logic is not something I know how to do.
Help? D:
[Resolved] How to "disable" control.lua...?
[Resolved] How to "disable" control.lua...?
Last edited by kirazy on Fri Jun 08, 2018 10:50 pm, edited 1 time in total.
Re: How to "disable" control.lua if a different mod is present?
So you can check if the mod is active using:
http://lua-api.factorio.com/latest/LuaG ... ctive_mods
And then in your event calls, just return if the other mod is present:
http://lua-api.factorio.com/latest/LuaG ... ctive_mods
And then in your event calls, just return if the other mod is present:
Code: Select all
script.on_event(defines.events, function(event)
if game.active_mods["OtherLoaderMod"] then return end
on_event(event) --etc.
end
Re: How to "disable" control.lua if a different mod is present?
You can check for presence of other mods like this:
You need to use the mod name from json file and you can decide which parts of code to cut if it's present.
Code: Select all
if game.active_mods["pyfusionenergy"] then
--code here
end
Re: How to "disable" control.lua if a different mod is present?
This worked, thank you very much.Klonan wrote:So you can check if the mod is active using:
http://lua-api.factorio.com/latest/LuaG ... ctive_mods
And then in your event calls, just return if the other mod is present:
Code: Select all
script.on_event(defines.events, function(event) if game.active_mods["OtherLoaderMod"] then return end on_event(event) --etc. end

- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: How to "disable" control.lua if a different mod is present?
Wouldn't it be more prudent to not define the event in the first place?Klonan wrote:And then in your event calls, just return if the other mod is present:Code: Select all
script.on_event(defines.events, function(event) if game.active_mods["OtherLoaderMod"] then return end on_event(event) --etc. end
Code: Select all
local skip = game.active_mods["OtherLoaderMod"] and true or false
if not skip then script.on_event(defines.events.on_stuff_happend,function(event)
--do more stuff
end) end
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: [Resolved] How to "disable" control.lua...?
IF you know what his settings are (and you're probably going to want to do this any way in case he changes them), you can just check to see if the setting exists.
Re: How to "disable" control.lua if a different mod is present?
'game' namespace isn't available when the script is loading, so you would have to conditionally register the event within the on_load, which is more hassle and riskeradicator wrote:Wouldn't it be more prudent to not define the event in the first place?Klonan wrote:And then in your event calls, just return if the other mod is present:Code: Select all
script.on_event(defines.events, function(event) if game.active_mods["OtherLoaderMod"] then return end on_event(event) --etc. end
Code: Select all
local skip = game.active_mods["OtherLoaderMod"] and true or false if not skip then script.on_event(defines.events.on_stuff_happend,function(event) --do more stuff end) end
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: How to "disable" control.lua if a different mod is present?
Hm...true. Why is that table in game then though, it can't change at that point can it?Klonan wrote:'game' namespace isn't available when the script is loading, so you would have to conditionally register the event within the on_load, which is more hassle and riskeradicator wrote:Wouldn't it be more prudent to not define the event in the first place?Klonan wrote:And then in your event calls, just return if the other mod is present:Code: Select all
script.on_event(defines.events, function(event) if game.active_mods["OtherLoaderMod"] then return end on_event(event) --etc. end
Code: Select all
local skip = game.active_mods["OtherLoaderMod"] and true or false if not skip then script.on_event(defines.events.on_stuff_happend,function(event) --do more stuff end) end