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

no edit summary
imported>Cipscis
m (Minor change to script comment)
imported>Omzy
 
(7 intermediate revisions by 2 users not shown)
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 sIsAffected != 1
  set rIsAffected to IsAffectedRef
set sIsAffected to 1
endif
   
   
  End
  End
Line 21: Line 19:
   
   
  short sDoOnce
  short sDoOnce
ref rIsAffected
   
   
  Begin BlockName
  Begin BlockName
Line 30: Line 29:
  ; without preventing the OnLoad block from running
  ; without preventing the OnLoad block from running
  else
  else
  if ObjectRefID.sIsAffectedPluginName == 1
set rIsAffected to ObjectRefID.rIsAffected
  if rIsAffected.GetIsReference IsAffectedRef
  ; Object has not been overridden
  ; Object has not been overridden
  else
  else
Line 38: Line 38:
   
   
  End
  End
[[Category:Solutions]]
 
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 ==
*[[Running_an_OnLoad_block_on_a_disabled_item|Running an OnLoad block on a disabled item]]
 
[[Category:Advanced_Modding_Techniques]]
Anonymous user