Checking if a Mod is affecting an Object

From the Fallout3 GECK Wiki
Revision as of 23:33, 19 December 2008 by imported>Cipscis (Corrected variable name)
Jump to navigation Jump to search

Many plugins will edit Objects that originate from a Master file instead of, or as well as, creating their own new Objects. While this is a perfectly viable way of editing an item, the possibility that the edit will be overridden should be taken into account.

If two plugins edit the same Object, only one of these edits will be used in game. Which edit "wins" depends on which plugin is loaded last - this is controlled by the user as opposed to the author of the plugin. Because of this, the author of the plugin should always take into account the possibility that one or more of their edits may be overridden.

One way to check whether or not an Object has been overridden by another plugin is to attach a script that contains an "sIsAffected" variable:

ScriptName GenericIsAffectedSCRIPT

short sIsAffectedPluginName

Begin OnLoad

	if sIsAffectedPluginName != 1
		set sIsAffectedPluginName to 1
	endif

End

If an Object has a script attached to it with an OnLoad block like the one above, it is possible to check whether or not the edit has been overridden. To do this, you'll need to make an empty cell (just copy one of the Dummy Cells in Fallout3.esm) and place a reference of the Object you've editted in the cell.

Now, set the reference as a Persistent Reference and give it a unique ObjectRefID. Whenever you want to check whether or not the Object has been overridden, use a script like this:

ScriptName GetIsAffectedSCRIPT

short sDoOnce

Begin BlockName

	if sDoOnce == 0
		set sDoOnce to 1
		ObjectRefID.MoveTo player
		ObjectRefID.SetScale 0 ; Effectively disables the reference
		; without preventing the OnLoad block from running
	else
		if ObjectRefID.sIsAffectedPluginName == 1
			; Object has not been overridden
		else
			; Object has been overridden
		endif
	endif

End