Can two mods "talk" - pass messages?

Post » Mon Feb 11, 2013 10:00 am

Is there a safe way for two mods to talk to each other such as to pass script calls, etc?

Case in point, I have a mod that requires some extra items for Hearthfire and Dragonboredn. I'd like to add scripts to HF/DB that pass events and refs to my main mod for processing... for example a spell script.

I don't want to have to make multiple versions of my mod... "Vanilla! HF! DB! HFDB!"...thats just silly. In programming terms I'm looking for a way to make a Singleton or some kind of broadcast system. Worst case I think would be to convert my main mod into an ESM but that seems a bit extreme.

Is there a better solution?
User avatar
Tarka
 
Posts: 3430
Joined: Sun Jun 10, 2007 9:22 pm

Post » Mon Feb 11, 2013 6:26 am

http://www.creationkit.com/GetFormFromFile_-_Game can be used to do such stuff. There's an example on its page that will detect loading/unloading plugins. If the parent plugin of the spell's script is detected, it should be safe to count on it being available.

Spell DLC1VampireBats = Game.GetFormFromFile(0x000038B9, "Dawnguard.ESM") As SpellIf DLC1VampireBats;!= None	DLC1VampireBats.Cast(PlayerREF, MQ101AlduinREF)EndIf
User avatar
Cayal
 
Posts: 3398
Joined: Tue Jan 30, 2007 6:24 pm

Post » Mon Feb 11, 2013 6:59 pm

I recommend you take a look at http://www.creationkit.com/GetFormFromFile_-_Game SKSE's RegisterForModEvent and SendModEvent functions, which can be used to pass information back and forth between mods via script without requiring dependencies.

Cipscis

EDIT:

Looks like I just got ninjad.

Cipscis
User avatar
Danial Zachery
 
Posts: 3451
Joined: Fri Aug 24, 2007 5:41 am


Return to V - Skyrim