Checking a "non exisent" variable

Post » Fri Dec 02, 2011 8:00 am

For a Mod I'm working on, I want to be able to check a Mod which the Player MAY have Installed, but does not HAVE to-- I want to check a specific Variable related with this Mod, but don't want to have it as a Master-- but of course, the CS won't allow you to save a Script with an unknown Variable, so is there a way I can actually do this?

I figured I could just load the two Mods into the CS at once, with one inactive, but I'm guessing it will suffer from the "Can't use other .esp file data" issue...
User avatar
Bedford White
 
Posts: 3307
Joined: Tue Jun 12, 2007 2:09 am

Post » Fri Dec 02, 2011 1:18 pm

De-isolation in general is described http://cs.elderscrolls.com/constwiki/index.php/De-Isolation_Tutorial and I think I've used script variables that way.
User avatar
NAtIVe GOddess
 
Posts: 3348
Joined: Tue Aug 15, 2006 6:46 am

Post » Fri Dec 02, 2011 7:15 pm

De-isolation, and esmifying the other mod in order to load it as a master with your mod will work, but that makes the other mod a master for your mod, and that seems to not be what you want, as that would crash Oblivion if you try to start it with your mod loaded and without the other mod.

So you have two choices, either making two versions of your mod, one standalone and one with the other mod as a master, or - much better - turn to OBSE. OBSE has a number of great, easy-to-use cross-mod functions. The most important are:

IsModLoaded "" - returns true if is loaded.
set myRef to GetFormFromMod "" "" - sets your local ref variable to refer to an object defined in another mod. The ref variable can then be used just like any other.
RunScriptLine "<scriptline>" - runs one script line that don't need to be valid in the CS, just as if you opened the console ingame and wrote the text. For example:
RunScriptLine "set myQuest.myVar to questFromOtherMod.otherVar" will set your local "myVar" variable to the value of the quest variable in another mod.
User avatar
Clea Jamerson
 
Posts: 3376
Joined: Tue Jun 20, 2006 3:23 pm

Post » Fri Dec 02, 2011 7:43 pm

Thanks, that sounds helpful-- and deisolation was useful, too, for something else :)

One quick check, does IsModLoaded need the .esp extension? I assume so, but since it's checking for Mods anyway...
User avatar
Hannah Barnard
 
Posts: 3421
Joined: Fri Feb 09, 2007 9:42 am

Post » Fri Dec 02, 2011 3:01 pm

Yes, .esp/.esm extension required.

If you're checking for a global variable you can use GlobalVariableExists "varname".
User avatar
Stryke Force
 
Posts: 3393
Joined: Fri Oct 05, 2007 6:20 am


Return to IV - Oblivion

cron