enderalse/source/scripts/_00e_autosavesystem_functions.psc

83 lines
2.2 KiB
Plaintext

Scriptname _00E_AutoSaveSystem_Functions extends Quest
; Save Name Structure (from NQS NamedQuicksaves by Ryan McKenzie)
; Save3_0C2D58E2_0_507269736F6E6572_Tamriel_000002_20180503063315_4_1.ess
; Save3: Type and index of save
; 0C2D58E2: Unique hash used to identify your save profile. Regenerated on closing racemenu.
; 0: Flag for modded game.
; 507269736F6E6572: Character name in hex.
; Tamriel: coc code.
; 000002: Days, hours, minutes played.
; 20180503063315: Year, month, day, hour, minute, second in GMT + 0.
; 4: Player level.
; 1: Unknown flag.
Event OnUpdate()
If bAutosaveSystemStopped
return
EndIf
Actor PlayerREF = Game.GetForm(0x14) as Actor
If PlayerREF.IsInCombat() || ! Game.IsFightingControlsEnabled() || PlayerREF.IsDead() || Utility.IsInMenuMode() || UI.IsTextInputEnabled() || UI.IsMenuOpen("Dialogue Menu")
RegisterForSingleUpdate(5)
return
endif
; Eddoursul: Index prefixed with 0 ensures the engine does not rotate these saves out
Game.SaveGame("Autosave0" + iAutosaveIndex + "_" + EnderalFunctions.GetPlayerHash() + "_0_" + EnderalFunctions.StringToHex(PlayerREF.GetActorBase().GetName()) + "_EnderalSE_000000_00000000000000_1_1")
iAutosaveIndex += 1
if iAutosaveIndex >= Utility.GetIniInt("iAutoSaveCount:SaveGame")
iAutosaveIndex = 0
endif
RegisterForSingleUpdate(fUpdateTime*60)
EndEvent
; called from _00E_AutosaveIntervalAlias to update ini setting fAutosaveEveryXMins in case it was changed
Function UpdateAutoSaveInterval()
fUpdateTime = GetAutosaveEveryXMins()
RegisterForSingleUpdate(fUpdateTime*60)
EndFunction
Function StopAutosaveSystem()
bAutosaveSystemStopped = true
UnregisterForUpdate()
EndFunction
Function ResumeAutosaveSystemInXMinutes(float _fMinutes = 0.0)
If _fMinutes == 0.0
_fMinutes = fUpdateTime
If _fMinutes <= 0.0 ; just in case
_fMinutes = 30
EndIf
EndIf
RegisterForSingleUpdate(_fMinutes*60)
bAutosaveSystemStopped = false
EndFunction
float function GetAutosaveEveryXMins()
float fUpdateMinutes = Utility.GetIniFloat("fAutosaveEveryXMins:SaveGame")
If fUpdateMinutes <= 0.0 ; just in case
fUpdateMinutes = 30
EndIf
return fUpdateMinutes
endfunction
bool bAutosaveSystemStopped = false
int iAutosaveIndex = 0
float fUpdateTime