hubbawubba Posted July 26, 2017 Share Posted July 26, 2017 Hi, I have been going crazy over this issue. I have spent the last two hours trying to make this work. The problem is that global variables are not working for me. I am new to modding by the way. Here is the issue. I got to the start of a script and put the declaration for my global variable like this: GlobalVariable Property BlaGlobal Auto Then, I go ahead and set the value on a function like this: BlaGlobal.SetValue(1) When I try to retrieve it later on like: float temp = BlaGlobal.GetValue() I always get the 0.00000 value. I have tried getting the reference for the BlaGlobal using: debug.Notification("Global ref =" + BlaGlobal) It is always none. What am I doing wrong? I have followed the documentation to the letter. I even tried starting from a clean save without a single mod on it. That did not help either. Is there some kind of initialization to global variables or something? Thanks. Link to comment Share on other sites More sharing options...
RichWebster Posted July 26, 2017 Share Posted July 26, 2017 Did you assign the property to the global variable? You can't just declare it in a script. Link to comment Share on other sites More sharing options...
hubbawubba Posted July 26, 2017 Author Share Posted July 26, 2017 Did you assign the property to the global variable? You can't just declare it in a script.Hi, how do I do that? Link to comment Share on other sites More sharing options...
foamyesque Posted July 26, 2017 Share Posted July 26, 2017 Did you assign the property to the global variable? You can't just declare it in a script.Hi, how do I do that? Select the script in the script window, and either hit the "edit properties" button on the right, or right-click on it and choose "edit properties" from there. It'll pull up a popup window that will let you fill in the properties with appropriate editor objects. Link to comment Share on other sites More sharing options...
hubbawubba Posted July 26, 2017 Author Share Posted July 26, 2017 foamyesque, how do I do this programmatically cause I am only using the CK compiler without the full application. Link to comment Share on other sites More sharing options...
RichWebster Posted July 26, 2017 Share Posted July 26, 2017 The only way would be to assign the global using GetFormFromFile(), but you'll need to know the form ID of the global variable. http://www.creationkit.com/index.php?title=GetFormFromFile_-_Game So you'd have your script property as: GlobalVariable MyGlobal = None Then in the first function call of your script: MyGlobal = Game.GetFormFromFile() And fill in the function properly using the link above. Link to comment Share on other sites More sharing options...
hubbawubba Posted July 26, 2017 Author Share Posted July 26, 2017 So, the only way to use those global variables is to actually have them in an ESP file and then using the Game.GetFormFromFile(), and then I have a reference to that variable in which I can get its value and set it. Did I get this right? Link to comment Share on other sites More sharing options...
RichWebster Posted July 26, 2017 Share Posted July 26, 2017 So, the only way to use those global variables is to actually have them in an ESP file and then using the Game.GetFormFromFile(), and then I have a reference to that variable in which I can get its value and set it. Did I get this right?That's right mate. Is there any reason you can just use a float or integer? Link to comment Share on other sites More sharing options...
hubbawubba Posted July 27, 2017 Author Share Posted July 27, 2017 Thanks a lot for the information, B1gBadDaddy. It is much appreciated. The problem is I want to carry the information between sessions. I ended up using StorageUtil which does not force me to use the ESP files. Link to comment Share on other sites More sharing options...
foamyesque Posted July 27, 2017 Share Posted July 27, 2017 Thanks a lot for the information, B1gBadDaddy. It is much appreciated. The problem is I want to carry the information between sessions. I ended up using StorageUtil which does not force me to use the ESP files. Script variables are saved between sessions too. Link to comment Share on other sites More sharing options...
Recommended Posts