Accessing global variables from other mods

Post » Tue Jun 19, 2012 4:33 pm

Hi,

Must be something I missed, but I searched this Forum, Google, Nexus and CK-wiki and found nothing usable.

Q: How to access global variables from other mods?

I tried to load another .esp as a plugin and managed to get its variables shown in CK. Then I put one of them in my script's properties and tried to read & write it with no success. I read something that I should use .esm, but is that still the case?
User avatar
ONLY ME!!!!
 
Posts: 3479
Joined: Tue Aug 28, 2007 12:16 pm

Post » Wed Jun 20, 2012 4:27 am

The problem with this is, it all depends on the load order...if the mod that is dependant on the globals loads first, it will fail to find the variables it's expecting.
User avatar
JLG
 
Posts: 3364
Joined: Fri Oct 19, 2007 7:42 pm

Post » Wed Jun 20, 2012 3:33 am

Damn, I already let myself joy about the quick solution, but it didn't work...

Originally, I had Data Files / Load Order:

MyMod
TheOtherMod

I changed it to:

TheOtherMod
MyMod

Still the .GetValue() gets me 0.0000 when the console command gets me 3.0000.

What do I do wrong?
User avatar
Sarah Knight
 
Posts: 3416
Joined: Mon Jun 19, 2006 5:02 am

Post » Tue Jun 19, 2012 9:55 pm

While the game has no problem with it, the Creation Kit will not allow one data file to be the master of another data file unless it has the ESM flag set in its file header.

In order to access data from one ESP file in another ESP file, it's necessary to set that bit (I think there are a few 3rd party utilities with this feature, although I've not had to do it myself for Skyrim) in the file that you want to be a master (leaving the file extension as it is) before you use it in the Creation Kit. After editing, the bit should be reset, but it needs to be specified as a master file whenever you open its "slave" in the Creation Kit.

Cipscis
User avatar
Max Van Morrison
 
Posts: 3503
Joined: Sat Jul 07, 2007 4:48 pm

Post » Wed Jun 20, 2012 2:24 am

That sounds awfully clumsy way to do something so simple...

I could do that, yes, but how about others who use my mod and that another mod? Would I have to guide them to do the same thing themselves?

There must be an easier workaround, otherwise shame on you Beth'... This should really be a basic thing.

A thought: Is there a way to run console commands in a script? Because if so, I'd run a "SET" command to modify the value right there. Or I could tell the script to run an external BAT, which I could include in the mod package.

More suggestions, anyone?
User avatar
Mason Nevitt
 
Posts: 3346
Joined: Fri May 11, 2007 8:49 pm

Post » Wed Jun 20, 2012 1:35 am

To get with a first .esp the value of a Global modified by a second .esp, you must update the Global with UpdateCurrentInstanceGlobal, in a Quest script of your second .esp. The Global must also be added to the Global list of your Quest.
User avatar
N3T4
 
Posts: 3428
Joined: Wed Aug 08, 2007 8:36 pm

Post » Tue Jun 19, 2012 7:22 pm

I could do that, yes, but how about others who use my mod and that another mod? Would I have to guide them to do the same thing themselves?
No, this is only required when editing the file. Like I said, the game doesn't have any problem with it, but the Creation Kit does. This was the case for previous games like Oblivion and Fallout 3, too.

A thought: Is there a way to run console commands in a script? Because if so, I'd run a "SET" command to modify the value right there. Or I could tell the script to run an external BAT, which I could include in the mod package.
There is no way in which you can run console commands from Papyrus. The two systems are completely independent, sharing no code and not talking to one another.

Cipscis
User avatar
Rebecca Dosch
 
Posts: 3453
Joined: Thu Jan 18, 2007 6:39 pm

Post » Wed Jun 20, 2012 4:15 am

Ha!

I actually managed to find a way to circumvent this whole obscurity...:

GlobalVariable OtherModGV
OtherModGV = Game.GetForm(0x01234567) as GlobalVariable

After that the variable is indeed accessible like i.e:

Debug.MessageBox(OtherModGV.GetValue())

I suspected there should be a more simpler way and there was! Anyway, thanks for taking part to this problem.

Only thing I do worry about now, is what happens, if someone uses another mod apart the mod I want to manipulate here... There could be the same hex value in any form (i.e. custom actor 0x01234567) not designed to be modified by my mod... And what if there are two of same values... But I can live with that for now. :)
User avatar
Judy Lynch
 
Posts: 3504
Joined: Fri Oct 20, 2006 8:31 am

Post » Tue Jun 19, 2012 9:45 pm

Using formIDs in Papyrus is a bad idea. Scripts should never be made directly aware of the content in a data file. If you need a script to interface with content in a data file, that's what properties are for.

I don't recommend ever using http://www.creationkit.com/GetForm_-_Game unless it's somehow required for debugging purposes only.

Cipscis
User avatar
Romy Welsch
 
Posts: 3329
Joined: Wed Apr 25, 2007 10:36 pm

Post » Tue Jun 19, 2012 9:28 pm

I am having a problem calling a custom GlobalVariable that is local to my mod.

Scriptname HumanAging extends Quest  GlobalVariable property GameDaysPassed auto  GlobalVariable property PlayerAge auto  GlobalVariable property GameHour autoEvent OnInit()Debug.Notification("Project Legacy - Aging Script Loaded.")RegisterForUpdateGameTime(1)CheckTimeOfDay()EndEventfunction CheckTimeOfDay()float TimeofDay = gamehour.getValue()  if (TimeOfDay == 0)  GotoState("Aging")   elseif (game.getplayer().isDead() == True)   UnregisterForUpdateGameTime()  endifendfunctionState AgingEvent OnUpdateGameTime()  int CurrentAge = PlayerAge.GetValueint()  float DaysPassed = GameDaysPassed.GetValue()  float YearCount = (DaysPassed) / 356  float Age = (CurrentAge) + (YearCount)  PlayerAge.SetValue(Age)  Debug.Notification("Project Legacy - Age Check: " + Age as int + " years old.")		 EndEventEndState

It seems to get the value of GameHour perfectly fine, but it always returns PlayerAge as 0 even though it is set as 21 by default.
User avatar
Austin Suggs
 
Posts: 3358
Joined: Sun Oct 07, 2007 5:35 pm

Post » Tue Jun 19, 2012 10:46 pm

Bumping for help.

EDIT:

Never mind. I figured it out.
User avatar
jessica breen
 
Posts: 3524
Joined: Thu Aug 03, 2006 1:04 am


Return to V - Skyrim