Or is it possible to attach a script to the player's onload event.
ScriptName YourQuestScript extends YourQuestScriptGlobalVariable Property bGameLoadedGLOB AutoEvent OnInit() RegisterForUpdate(5)EndEvent;==========================Event OnUpdate() If (bGameLoadedGLOB.GetValue() == 1) bGameLoadedGLOB.SetValue(0) ; Will set itself back to 1 before loading ANY save ;Do stuff once when a save is loaded EndIfEndEvent
ScriptName OnInitScript extends QuestImport DebugEvent OnInit() Debug.MessageBox("Initialized")EndEvent...attached to it. When the quest first loads, you'll get a MessageBox. Save, load said save, and there will be no MessageBox 'cause the quest has already initialized. If you want your code to run every time a save is loaded, the constant global is the way 'til we, hopefully, get a GetGameLoaded() function SKSE style. That is what you mean by "run once every time the game is loaded", right?
ScriptName OnInitScript extends QuestImport DebugEvent OnInit() Debug.MessageBox("Initialized")EndEvent...attached to it. When the quest first loads, you'll get a MessageBox. Save, load said save, and there will be no MessageBox 'cause the quest has already initialized. If you want your code to run every time a save is loaded, the constant global is the way 'til we, hopefully, get a GetGameLoaded() function SKSE style. That is what you mean by "run once every time the game is loaded", right?
ScriptName FunctionTestScript extends Quest{Demonstrates GetGameLoaded() function}Form Property ObscureItem AutoLeveledItem Property EmptyLVLI AutoObjectReference Propety SomeContainerREF AutoEvent OnInit() RegisterForSingleUpdate(3)EndEvent;;;;;;;;;;;;;;;;;;;;;;;;;;;;Event OnUpdate() RegisterForSingleUpdate(3) If GetGameLoaded(EmptyLVLI, ObscureItem, SomeContainerREF) Debug.Notification("GetGameLoaded()") ; Shows once per save load Else Debug.Notification("!GetGameLoaded()") ; Shows repeatedly EndIfEndEvent;;;;;;;;;;;;;;;;;;;;;;;;;;;;Bool Function GetGameLoaded(LeveledItem akLeveledItem = None, Form apItem = None, ObjectReference akContainer = None) akContainer.AddItem(akLeveledItem, 1, True) If akContainer.GetItemCount(apItem) akContainer.RemoveItem(apItem, akContainer.GetItemCount(apItem), True) Return False Else akLeveledItem.AddForm(apItem, 1, 1) Return True EndIfEndFunction
... Debug.Notification("GetGameLoaded() == " + GetGameLoaded(MaiqTheLiarREF))...Bool Function GetGameLoaded(Actor akActor = None) If akActor.GetActorValue("BrainCondition") akActor.SetActorValue("BrainCondition", 0) Return True Else Return False EndIfEndFunction
... Debug.Notification("GetGameLoaded() == " + GetGameLoaded(MaiqTheLiarREF))...Bool Function GetGameLoaded(Actor akActor = None) If akActor.GetActorValue("BrainCondition") akActor.SetActorValue("BrainCondition", 0) Return True Else Return False EndIfEndFunction