jrfk2 Posted October 31, 2016 Share Posted October 31, 2016 Hi Folks,using a quest script that runs at game load to add custom workshop categories .. is there a way in the script to set a value that will save in the game, that I can check in my quest script the next time they load that game? Link to comment Share on other sites More sharing options...
shavkacagarikia Posted October 31, 2016 Share Posted October 31, 2016 You are probably looking for global variables. check this: http://www.creationkit.com/index.php?title=Global Link to comment Share on other sites More sharing options...
jrfk2 Posted November 1, 2016 Author Share Posted November 1, 2016 Thanks, i added a GlobalVariable to my script as a property and do a .Mod(1.0) on it in my script when it runs, then do a save game, then load the game but the value is back to 0 .. I can;t seem to save a value that gets saved in the game ... Link to comment Share on other sites More sharing options...
shavkacagarikia Posted November 1, 2016 Share Posted November 1, 2016 You set the value of the global variable with GlobalvarProperty.setvalue(yourValue) function. Link to comment Share on other sites More sharing options...
jrfk2 Posted November 1, 2016 Author Share Posted November 1, 2016 (edited) Appreciate the help .. I had also tried a GlobalvarName.setValue(1.0), loaded the game / my quest , then saved the game, then loaded the game again, but the getValue() call came back with 0.00 (setting the getValue() to a float variable) .. when I was expecting the setValue() and then game save would have saved a value of 1.0 .. Guess I am still missing something about how my quest script can set a value that will be saved in the next game save so on the next load I will see the saved value. PS, in my property setting for my script this global var has a default value of "None" .. all CK wants to let me set the default value t is one of the objects in the game , which I don't want, I just want my own flag to know whether my mod has run before in the current game being loaded .. Edited November 1, 2016 by jrfk2 Link to comment Share on other sites More sharing options...
shavkacagarikia Posted November 1, 2016 Share Posted November 1, 2016 You must point to your global variable from properties. Without that CK just doesn't know value of which global variable you are changing Link to comment Share on other sites More sharing options...
jrfk2 Posted November 1, 2016 Author Share Posted November 1, 2016 Can GlobalVars only be used to update existing game objects? In CK, in the properties for my script .. my Globalvar is defined there .. but if I want to select a value for it, CK only seems to list like already defined objects in the game to select from .. and I was just looking for a way to save a "flag" in the game that my mod had been run once .. not update any of the games objects .. unless I can store my Globalvar "flag" in one of the game's objects and not cause it harm ...?? Link to comment Share on other sites More sharing options...
shavkacagarikia Posted November 1, 2016 Share Posted November 1, 2016 Hmm :confused: where have you created your global variable? It must be made under miscellanous/Global. You should then give it name and default value. Then in script you add a new property of type global variable and point to your created variable. Then you can edit that variable from script. If you define a variable in script thats not a global, thats a local variable. Link to comment Share on other sites More sharing options...
jrfk2 Posted November 2, 2016 Author Share Posted November 2, 2016 Yep .. sorry but I am def a noop ... appreciate your patience .. where do I find misc/Global? is that part of the script properties or the quest that runs the script? All I have done so far: I have a Quest that runs when the game loads and basically all it has is a script that it runs. I added a GlobalVariable to the properties for that script, but it has a default value of None as all there is to select for values are objects that are already defined. I have the getvalue() and setvalue() inside the script and that code runs when the game loads .. but the value is not saved when the game is saved.. So yeah, I am missing something someplace .. looked around but have not found a miscellaneous/Global yet .. thanks... Link to comment Share on other sites More sharing options...
kinggath Posted November 2, 2016 Share Posted November 2, 2016 In your script you'll have something like: GlobalVariable Property SomeVariableName Auto Const Now in the CK object window, create a global variable, doesn't matter what you name it as you'll link it to the SomeVariableName you defined in your script next. Now that you have your script saved, and your global variable form created, go to the form you have your script attached and click on Properties. This will bring up a window with all of your properties defined in your script, select SomeVariableName and click Edit Value, you'll then find the global variable form you created in a drop down, select it and click OK on the properties menu. Link to comment Share on other sites More sharing options...
Recommended Posts