Jump to content

MCGUFIN

  • entries
    9
  • comments
    0
  • views
    354

Load Order Monitor


Monoman1

53 views

I've often wondered how many OnPlayerLoadGame events are fired when you load a save. A huge chunk of these would be compatibility checks. 
 

Event OnPlayerLoadGame()
	If Game.GetModByName("CoolMod.esp") != 255
	; CoolMod is installed. 
        ; Do Stuff.
        
	Else
    	; CoolMod is not installed.
        ; Do other stuff.
    EndIf
EndEvent


Inefficient - How many of these checks end up doing nothing really? - Yup 'CoolMod.esp' still IS or is NOT installed. What percentage of save loads has your load order actually changed?

And it leads to a huge spike in papyrus activity right when you kind of don't want it. 

Alternatively you can register with MGF for load order change events and it will let you know when you need to check for real. 

Usage: 
 

Event OnInit()
	RegisterForModEvent("_MGF_LoadOrderChanged", "On_MGF_LoadOrderChanged")
EndEvent

 

Now any time mods:

  • are added. 
  • removed.
  • the order of mods changed (nothing was necessarily added or removed). 
  • the modified timestamp has changed on a plugin file. 
  • Something's actually changed. 

 

You'll get this event: 
 

Event On_MGF_LoadOrderChanged(Bool OrderChanged, Bool ModsAdded, Bool ModsRemoved, Bool ModsModified)
    ; OrderChanged - The order has simply changed since last load. 
    ; ModsAdded - Mods were added since the last load. 
    ; ModsRemoved - Mods were removed since last load. 
    ; ModsModified - At least one of the plugin files has been modified since the last load. 
    
    ; All these flags are set individually -> ModsAdded and ModsRemoved could both be true! 
EndFunction

 

You can use these functions to pull a list of what's changed: 
 

; Returns a string array of the mods added since last load. 
String[] Function GetAddedMods() Global Native

; Returns a string array of the mods removed since last load. 
String[] Function GetRemovedMods() Global Native

; Returns a string array of the mods modifed (time modified check) since last load. 
; Note this detects changes to the esp. And not changes to scripts (unless properties were changed).
String[] Function GetModifiedMods() Global Native

 

Additional functions that might be useful: 
 

; Returns a string array of the current load order. 
String[] Function GetCurrentLoadOrder() Global Native

; Returns a string array of the previous load order. 
String[] Function GetPreviousLoadOrder() Global Native

 

Example usage: 
 

Event On_MGF_LoadOrderChanged(Bool OrderChanged, Bool ModsAdded, Bool ModsRemoved, Bool ModsModified)
    If ModsAdded
        String[] AddedMods = _MGF_Util.GetAddedMods()
		If AddedMods.Find("CoolArmorMod.esp") > -1
			; Cool armor mod added. Add it's armors to my shop!
		EndIf
    EndIf
    
    If ModsRemoved
        String[] RemovedMods = _MGF_Util.GetRemovedMods()
        Debug.Notification("Removed " + RemovedMods.Length + " mods")
    EndIf
    
    If ModsModified
        String[] ModifiedMods = _MGF_Util.GetModifiedMods()
        If ModifiedMods.Find("CoolArmorMod.esp") > -1
			; Check if CoolArmorMod.esp added a new armor set for my shop!
		EndIf
    EndIf
    
    If OrderChanged
        Debug.Notification("Load order was rearranged")
        HandleOrderChange()
    EndIf
EndEvent

 

This load order event is used extensively in MGF's interface scripts. 

 

Edited by Monoman1

0 Comments


Recommended Comments

There are no comments to display.

×
×
  • Create New...