Checking if a Mod is affecting an Object
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 create a persistent "IsAffectedRef" reference and attach a script to the object that's being checked containing an "rIsAffected" variable:
ScriptName GenericIsAffectedSCRIPT short rIsAffected Begin OnLoad set rIsAffected to IsAffectedRef 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 ref rIsAffected 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 set rIsAffected to ObjectRefID.rIsAffected if rIsAffected.GetIsReference IsAffectedRef ; Object has not been overridden else ; Object has been overridden endif endif End
If you want to check whether or not a Mod is affecting an Object in a condition (for example, for a button on a message) then you'll have to use a bit of a workaround. Because these sorts of conditions can't check if a variable is equal to a reference, you'll have to do something like create a quest script declaring an "sObjectIsAffected" variable, and a result script like this:
set sQuestName.sObjectIsAffected to (ObjectRefID.rIsAffected == IsAffectedRef)
Now, you can check if "sQuestName.sObjectIsAffected == 1" in your condition.