enderalse/source/scripts/_00e_autosavesystem_functions.psc

58 lines
1.4 KiB
Plaintext
Raw Normal View History

Scriptname _00E_AutoSaveSystem_Functions extends Quest
Event OnUpdate()
Actor PlayerREF = Game.GetForm(0x14) as Actor
2024-01-26 22:10:06 +00:00
if PlayerREF.IsDead()
return
endif
2024-01-26 22:10:06 +00:00
If PlayerREF.IsInCombat() || PlayerREF.IsOnMount() || PlayerREF.IsSwimming() || ! Game.IsFightingControlsEnabled() || Utility.IsInMenuMode() || UI.IsTextInputEnabled() || UI.IsMenuOpen("Dialogue Menu") || ! PlayerREF.GetParentCell()
RegisterForSingleUpdate(5)
return
endif
2024-01-24 17:12:06 +00:00
Game.SaveGame(EnderalFunctions.GetAutosaveName(iAutosaveIndex))
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()
if SKSE.GetVersion() <= 0
UnregisterForUpdate()
Debug.Trace("NO SKSE: timed autosaves are disabled")
return
endif
fUpdateTime = Utility.GetIniFloat("fAutosaveEveryXMins:SaveGame")
If fUpdateTime <= 0.0 ; just in case
fUpdateTime = 30.0
EndIf
RegisterForSingleUpdate(fUpdateTime*60)
RegisterForMenu("Journal Menu")
EndFunction
Event OnMenuClose(String MenuName)
float fAutosaveEveryXMins = Utility.GetIniFloat("fAutosaveEveryXMins:SaveGame")
if fUpdateTime as int != fAutosaveEveryXMins as int
fUpdateTime = fAutosaveEveryXMins
RegisterForSingleUpdate(fUpdateTime*60)
endif
EndEvent
int iAutosaveIndex = 0
float fUpdateTime