Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

Ryuushu

Cross mod interaction?

Recommended Posts

Ryuushu    43

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?
 

Share this post


Link to post
Share on other sites
rezecib    3,122

@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

Share this post


Link to post
Share on other sites
Ryuushu    43

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!

Share this post


Link to post
Share on other sites
simplex    2,602

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.

Share this post


Link to post
Share on other sites