Difference between revisions of "Inter-mod Communication"

54 bytes removed ,  21:38, 22 June 2020
m
Corrected an obvious cut-and-paste error.
imported>LHammonds
m (fixed small typo)
imported>Docclox
m (Corrected an obvious cut-and-paste error.)
 
(3 intermediate revisions by 2 users not shown)
Line 40: Line 40:
Example:
Example:
<source lang="papyrus">
<source lang="papyrus">
Form newCompanionForm = Game.GetFormFromFile("SpecialCompanion.esp", 0x00015A4F)
Actor newCompanion = Game.GetFormFromFile(0x00015A4F, "SpecialCompanion.esp") as Actor
Actor newCompanion = newCompanionForm as Actor
if newCompanion
if newCompanion
   ; We've got ahold of the new companion from that other mod, maybe we can give them one of our special armor pieces?
   ; We've got ahold of the new companion from that other mod, maybe we can give them one of our special armor pieces?
Line 118: Line 117:
   ; We can't use the normal "as" operator, because that would add a dependency on the other mod.
   ; We can't use the normal "as" operator, because that would add a dependency on the other mod.
   ; So instead we use the CastAs function to make sure we're pointing at the right script.
   ; So instead we use the CastAs function to make sure we're pointing at the right script.
   ScriptObject bfVendor = aCharacter.CastAs("BeginningFantasyVendor")
   ScriptObject bfVendor = aVendor.CastAs("BeginningFantasyVendor")


   ; Now set the properties, again, we don't need to cast because our parameter values are
   ; Now set the properties, again, we don't need to cast because our parameter values are
Line 183: Line 182:
     Var[] params = new Var[1]
     Var[] params = new Var[1]
     params[0] = actorThatEntered
     params[0] = actorThatEntered
     relayScript.CallFunction("RegisterForSummon", actorThatEntered)
     relayScript.CallFunction("RegisterForSummon", params)
   endIf
   endIf
endEvent
endEvent
Anonymous user