First of all you need to have a GlobalVariable that stores the current value of your stat.
Stat Quest
1. Make a new quest. Untick everything then tick Allow Repeated Stages
2. Add the following script to it (dont forget to edit the stat name and the stat category index to suite your mod):
Scriptname StatQuestScript extends Quest GlobalVariable Property myStatGlobal AutoString sValuefunction Register() RegisterForMenu("Journal Menu") ;Debug.Notification("Registered")endFunctionfunction Unregister() UnregisterForMenu("Journal Menu")endFunctionevent OnMenuOpen(string a_menuName) ;Debug.Notification("Menu") UpdateCurrentInstanceGlobal(myStatGlobal) ; Not sure if this is necessary? sValue = http://forums.bethsoft.com/topic/1473779-tutorial-adding-a-new-stat/myStatGlobal.GetValueInt() as string string[] args = new string[4] args[0] ="My Stat" ; Stat name args[1] = sValue args[2] = "0" ; stat category index as string 0 = "General" args[3] = "" UI.InvokeStringA("Journal Menu", "_root.QuestJournalFader.Menu_mc.StatsFader.Page_mc.PopulateStatsList", args)endEvent3. Make two quest stages. Make one the start up stage and the other the shut down stage.
4. In the kmyQuest drop down select the quest script. Then add "kmyQuest.Register()" to the first stage and "kmyQuest.Unregister()" to the last
Maintenence Quest
1. Make a new global called "runningSKSE"
2. Make a new quest. Tick "StartGameEnabled" and make everything else blank
3. Add the following script:
Scriptname MaintenanceQuestScript extends Quest Float fVersionInt iSKSEGlobalVariable Property runningSKSE AutoQuest Property statQuest Auto Event OnInit() Maintenance() ; OnPlayerLoadGame will not fire the first timeEndEvent Function Maintenance() If fVersion < 1.00 ; <--- Edit this value when updating fVersion = 1.00 ; and this ; Update Code EndIf iSKSE = SKSE.GetVersionRelease() If iSKSE ;Debug.Notification("SKSE Detected") If runningSKSE.GetValueInt() == 0 runningSKSE.SetValueInt(1) statQuest.Start() EndIf Else If runningSKSE.GetValueInt() == 1 runningSKSE.SetValueInt(0) statQuest.Stop() EndIf EndIfEndFunction5. Add a new Alias. Call it "Player". Fill Type = Specific Reference (cell = (any), Ref = PlayerRef)
6. Add the following script to it:
Scriptname MaintenanceAliasScript extends ReferenceAlias MaintenanceQuestScript Property QuestScript Auto Event OnPlayerLoadGame() QuestScript.Maintenance()EndEventSKSE String file
1. Make a new txt document and add the following (remember it needs a TAB to separate the string from the translation, not a bunch of spaces):
$My Stat My Stat2. Use sublime to save it as "UTF16 LE with BOM", name it "yourEspName" + "_ENGLISH" (eg. myMod_ENGLISH.txt")
3. Now place it in ...data/interface/translations
The reason for the string file is to circumvent PopulateStatsList's habit of affixing whatever you write in the code with a "$"
Right i think thats it. Let me know if I missed anything
- Hypno