Open main menu
Home
Random
Log in
Settings
About the CreationKit Wiki
Disclaimers
the CreationKit Wiki
Search
Editing
Complete Example Scripts
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
= Maintenance/update code which runs once per save load and shows a message when a mod is updated or first loaded = *Requires Skyrim v1.6+: All event based, so no polling is necessary. For this method to work, two scripts are needed as [[OnPlayerLoadGame - Actor|OnPlayerLoadGame]] will not fire from a Quest script. <syntaxhighlight lang="Papyrus">ScriptName YourQuestScript extends Quest Float fVersion Event OnInit() Maintenance() ; OnPlayerLoadGame will not fire the first time EndEvent Function Maintenance() If fVersion < 1.01 ; <--- Edit this value when updating fVersion = 1.01 ; and this Debug.Notification("Now running YourModName version: " + fVersion) ; Update Code EndIf ; Other maintenance code that only needs to run once per save load EndFunction ;****************************************************** ScriptName YourPlayerAliasScript extends ReferenceAlias YourQuestScript Property QuestScript Auto Event OnPlayerLoadGame() QuestScript.Maintenance() EndEvent</syntaxhighlight> *Does not require Skyrim v1.6+: Has to poll, but will work reliably and can be fit in with existing, reiterating code. <syntaxhighlight lang="Papyrus">ScriptName YourQuestScript extends Quest Float fVersion Actor Property ActorFromYourMod Auto Event OnInit() RegisterForUpdate(10) EndEvent Event OnUpdate() If bGetGameLoaded(ActorFromYourMod, "BrainCondition") If fVersion < 1.01 fVersion = 1.01 Debug.Notification("Now running YourModName version: " + fVersion) ; Update Code EndIf ; Maintenance code Else ; Other, reiterating code if needed EndIf EndEvent Bool Function bGetGameLoaded(Actor akActor, String asActorValue = "") If akActor.GetActorValue(asActorValue) akActor.SetActorValue(asActorValue, 0) Return True ; Will have reverted to 100 upon save load since BrainCondition is obsolete and not stored in saves Else Return False EndIf EndFunction</syntaxhighlight>
Summary:
Please note that all contributions to the CreationKit Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see
CreationKit:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)