Jump to content

Cross mod interaction?


Recommended Posts

How can I do it?
 
Right now I'm trying to do
 

AddGamePostInit( function()    if GLOBAL.KnownModIndex:IsModEnabled("The Other Mod") then        print("Mod I wanna modify is enabled!")        AddPrefabPostInit( function (inst) ... end)    endend)

However, The Other Mod is never found.

 

Is it because I call it before the mod is loaded? Or am I trying to do it horribly wrong?
 

Link to comment
Share on other sites

@Ryuushu, I just did a quick dump of that table in a test mod, and tried calling IsModEnabled on the console. Are you using the fancyname of the mod, or the workshop-####### name? Because the workshop name is what it uses for IsModEnabled.

 

If you want to use the fancyname, you can do this:

GLOBAL.KnownModIndex:IsModEnabled(GLOBAL.KnownModIndex:GetModActualName("The Other Mod"))

Also, out of curiosity, when does an AddGamePostInit run? I've never seen it used before o_o

Link to comment
Share on other sites

Ah, of course x.x I didn't know GetActualName existed.
 
Oh, about the running order, it goes Components -> Prefabs -> Sim -> Game. Or at least that's what I believe. I tested it with the following:

AddSimPostInit( function ()    print("Test0")end)AddGamePostInit(function ()    print("Test1")end)AddPrefabPostInit("evergreen", function(inst)    print("Test2")end)AddComponentPostInit("burnable", function(Burnable,inst)    print("Test3")end)

Which gives as result:

...Test3...Test2 x the amount of trees in your world x.x...Test 0...Test1

... But, when I tried to modify the other mod inside AddGamePostInit, it didn't let me do so. I think it was too late for that.

 

Anyways, thank you very much!

Edited by Ryuushu
Link to comment
Share on other sites

Also, out of curiosity, when does an AddGamePostInit run? I've never seen it used before o_o

AddGamePostInit is the weirdest of postinits. It's actually called from within the function CheckControllers :razz:.

Check mainfunctions.lua. Its point is that it runs after all game initialisation is done (but sim postinits run after pretty much everything has been initialised anyway). The strange thing is that, if controllers are not connected, then it does run right after initialisation is done, but if there are controllers attached it runs inside a callback 0.05 seconds into the game.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...