Difference between revisions of "Checking if a Mod is affecting an Object"

Corrected 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 contains an "sIsAffected" variable:
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 sIsAffectedPluginName
  short rIsAffected
   
   
  Begin OnLoad
  Begin OnLoad
   
   
  if sIsAffectedPluginName != 1
  set rIsAffected to IsAffectedRef
set sIsAffectedPluginName to 1
endif
   
   
  End
  End
Line 30: Line 28:
  ; without preventing the OnLoad block from running
  ; without preventing the OnLoad block from running
  else
  else
  if ObjectRefID.sIsAffectedPluginName == 1
  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 ==
Anonymous user