fishburger67 Posted March 24, 2018 Posted March 24, 2018 In Oldrim, if I added a new Property to a script on a quest, I could get the script to load the new property like this: Scriptname test extends SKI_ConfigBase ..... test2.reset() test2.stop() Utility.wait(0.5) test2.start() ;Reload all new variables and aliases ....... Scriptname test2 extends Quest GlobalVariable Property aGlobal Auto function setAGlobal(int value) aGlobal.setValue(val) endFunction int function getAGlobal() return aGlobal.getValue() endFunction In the above code, test.psc is calling reset, stop and start on test2.psc. The purpose is to have the newly added Property "aGlobal" get loaded properly . This is assuming that we are loading a save game that originally did not have test2.aGlobal. This all used to work just fine in OldRim, but in SSE, I am getting errors like "ERROR: Cannot call GetValue() on a None object, aborting function call" if I call getAGlobal(); If I start a brand new game, it all works fine. It is only a problem when I am testing a save game where the code did not have the new Property.a Anyone have an idea how to do this ? I know reset, start, and stop are being called because I have some trace code that is writing to the log file.
Ashal Posted March 24, 2018 Posted March 24, 2018 The new properties form likely isn't getting set. An easy fix would be to add a quick fill check like this: Scriptname test2 extends Quest GlobalVariable Property aGlobal Auto function setAGlobal(int value) if !aGlobal aGlobal = Game.GetFormFromFile(0x???, "???.esp") as GlobalVariable endIf aGlobal.setValue(val) endFunction int function getAGlobal() if !aGlobal aGlobal = Game.GetFormFromFile(0x???, "???.esp") as GlobalVariable endIf return aGlobal.getValue() endFunction
Teutonic Posted March 24, 2018 Posted March 24, 2018 Alternatively, you could use some sort of update procedure that simply uses GetFormFromFile to set the property to the desired value. This way it will only execute once when you update and you don't have go through an if statement every time you want to access the property.
fishburger67 Posted March 30, 2018 Author Posted March 30, 2018 On 3/24/2018 at 2:39 AM, Ashal said: The new properties form likely isn't getting set. An easy fix would be to add a quick fill check like this: Scriptname test2 extends Quest GlobalVariable Property aGlobal Auto function setAGlobal(int value) if !aGlobal aGlobal = Game.GetFormFromFile(0x???, "???.esp") as GlobalVariable endIf aGlobal.setValue(val) endFunction int function getAGlobal() if !aGlobal aGlobal = Game.GetFormFromFile(0x???, "???.esp") as GlobalVariable endIf return aGlobal.getValue() endFunction Turns out that the property did not get set because I added the property to the script, started a game and saved, but forgot to actually add the global value to the esp. Starting a new game had the property set correctly after the global was added. Thanks so much for this. I will use this technique in the future.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.