0=General
1=Quest
2=Combat
3=Magic
4=Crafting
5=Crime
Creating the Global
The Stat Quest
2. Add the following script to your quest by "Add"-ing a new script to the Scripts tab of your quest (don't forget to edit the stat name and the stat category index to suite your stat):
Scriptname StatQuestScript extends Quest
GlobalVariable Property myStatGlobal Auto
;fill the global property so it points to your global
String sValue
function Register(); learn more about custom functions
RegisterForMenu("Journal Menu")
;an SKSE function so the script will receive events when the journal menu is opened
endFunction
function Unregister()
UnregisterForMenu("Journal Menu")
endFunction
event OnMenuOpen(string a_menuName)
;when a registered menu is opened
UpdateCurrentInstanceGlobal(myStatGlobal)
;update the global to show a new value if neccessary
sValue = myStatGlobal.GetValueInt() as string
;our string variable = the value of our stat global
string[] args = new string[4]
;declaring a string array variable
args[0] = "My Stat";your stat name - change as necessary
args[1] = sValue;our stat value
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)
endEvent
4. For both stages, right-click in the top list area and add a new "Quest Stage Item". This makes the papyrus fragment section available.
5. Now add a semi-colon (;) in the fragment area and hit the compile button. Now "OK" out of the quest and open it again (this allows the CK time to generate the blank script).
6. For both stages, in the kmyQuest drop down select the quest script we made previously. Then replace the semi-colons with "kmyQuest.Register()" for the first stage and "kmyQuest.Unregister()" for the last stage.
Setting Your Stat
TotalKills.SetValue(QueryStat("People killed") + QueryStat("Animals killed") + QueryStat("Creatures killed") + QueryStat("Undead killed") + QueryStat("Automatons killed") + QueryStat("Daedra killed"))
Maintenance Quest
2. Make a new quest. Tick "StartGameEnabled" and make everything else blank. (As before, click OK then open it up again.)
3. Add the following script to your quest, in the same way we did earlier:
Scriptname MaintenanceQuestScript extends Quest
Float fVersion
Int iSKSE
GlobalVariable Property runningSKSE Auto
;fill this property
Quest Property statQuest Auto
;fill this property
Event OnInit()
Maintenance() ; OnPlayerLoadGame will not fire the first time
EndEvent
Function Maintenance()
If fVersion < 1.00 ; edit this value for each new version of your mod - i.e. version 1.1 ;would have 1.1.0 here
fVersion = 1.00 ; and edit this value to the version number of your mod
; Update Code - do any updating code (under script versioning on that page)
EndIf
iSKSE = SKSE.GetVersionRelease()
If iSKSE
;SKSE installed
If runningSKSE.GetValueInt() == 0
runningSKSE.SetValueInt(1)
statQuest.Start()
EndIf
Else
If runningSKSE.GetValueInt() == 1
runningSKSE.SetValueInt(0)
statQuest.Stop()
EndIf
EndIf
EndFunction
6. Add the following script to your player alias:
Scriptname MaintenanceAliasScript extends ReferenceAlias
MaintenanceQuestScript Property QuestScript Auto
;replace MaintenanceQuestScript with the scriptname of the script we just created
Event OnPlayerLoadGame()
QuestScript.Maintenance()
EndEvent
SKSE String File
$My Stat My Stat
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 "$"
Multiple Stats
event OnMenuOpen(string a_menuName)
UpdateCurrentInstanceGlobal(stat1Global)
UpdateCurrentInstanceGlobal(stat2Global)
UpdateCurrentInstanceGlobal(stat3Global)
sValue1 = stat1Global.GetValueInt() as string
sValue2 = stat2Global.GetValueInt() as string
sValue3 = stat3Global.GetValueInt() as string
string[] args = new string[12]
args[0] = "Stat 1"
args[1] = sValue1
args[2] = "0" ; stat category index as string
args[3] = ""
args[4] = "Stat 2"
args[5] = sValue2
args[6] = "0" ; stat category index as string
args[7] = ""
args[8] = "Stat 3"
args[9] = sValue3
args[10] = "0" ; stat category index as string
args[11] = ""
UI.InvokeStringA("Journal Menu", "_root.QuestJournalFader.Menu_mc.StatsFader.Page_mc.PopulateStatsList", args)
endEvent
Strings/Words as Stats
int iFactionRank = PlayerREF.GetFactionRank(YourFaction)
; Your Faction Rank
args[36] = "My Faction Rank" ; Stat name
if iFactionRank == 0
args[37] = "Rank 1";stat value
elseif iFactionRank == 1
args[37] = "Rank 2"
elseif iFactionRank == 2
args[37] = "Rank 3"
elseif iFactionRank == 3
args[37] = "Rank 4"
elseif iFactionRank == 4
args[37] = "Rank 5"
elseif iFactionRank == 5
args[37] = "Rank 6"
elseif iFactionRank == 6
args[37] = "Rank 7"
elseif iFactionRank == 7
args[37] = "Rank 8"
else
args[37] = "None"
endif; and on an on as necessary
args[38] = "1" ; stat category index as string 1 = "Quests"
args[0] = "Player's Name"
args[1] = Game.GetPlayer().GetName()
args[2] = "0" ; stat category index as string
args[3] = ""
args[4] = "Alias' Name"
args[5] = MyAlias.GetActorReference().GetName()
args[6] = "0"; stat category index as string
args[3] = ""