Difference between revisions of "Checking if a Mod is affecting an Object"
Checking if a Mod is affecting an Object (edit)
Revision as of 05:45, 17 January 2009
, 05:45, 17 January 2009Corrected information to relieve DragoonWraith's concern
imported>Cipscis (Added "See Also" link to "Running an OnLoad block on a disabled item") |
imported>Cipscis (Corrected information to relieve DragoonWraith's concern) |
||
Line 3: | Line 3: | ||
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. | 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 | 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 | ScriptName GenericIsAffectedSCRIPT | ||
short | short rIsAffected | ||
Begin OnLoad | Begin OnLoad | ||
set rIsAffected to IsAffectedRef | |||
End | End | ||
Line 30: | Line 28: | ||
; without preventing the OnLoad block from running | ; without preventing the OnLoad block from running | ||
else | else | ||
if ObjectRefID. | if ObjectRefID.rIsAffected == IsAffectedRef | ||
; Object has not been overridden | ; Object has not been overridden | ||
else | else | ||
Line 38: | Line 36: | ||
End | 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. | |||
== See Also == | == See Also == |