cheejins Posted October 12, 2020 Share Posted October 12, 2020 Hey yall, I have 2 scripts in Fallout 4 Creation Kit: Script A has array properties that point to spawn point markers.Script B needs to act as a global script and contains the logic of spawning NPCs.I need Script B to access script A's XMarker properties so I can spawn NPCs at those markers.Right now I'm trying to set a ScriptObject property to link the scripts together but am having trouble with this method because it's probably wrong. I'm new to CK and would really appreciate some help with this concept as it's a core feature to a mod I'm trying to make. Thanks. Link to comment Share on other sites More sharing options...
SKKmods Posted October 12, 2020 Share Posted October 12, 2020 Several approaches. I assume your hanging your scripts off of a quest: (a1) In script A define your array as a property so it can be accessed remotely: Scriptname QuestAScript extends Quest ObjectReference[] Property ListOfMarkers Auto ;Need to create ListOfMarkers = New ObjectReference[0] ;Need to build ListOfMarkers.Add(Marker) (a2) In script B access the remote script, remembering its a pointer so any changes are actually on the remote array: Quest Property pQuestA Auto Const Mandatory Function GetArrayA() ObjectReference[] LocalArrayPointer = (pQuestA as QuestAScript).ListOfMarkers EndFunction (b1) Or in script A publish a function that exposes the array Scriptname QuestAScript extends Quest ObjectReference[] ListOfMarkers ObjectReference[] Function GetListOfMarkers() Return ListOfMarkers EndEvent (b2) In script B call the remote function Quest Property pQuestA Auto Const Mandatory Function MyFunction() ObjectReference[] LocalArrayPointer = (pQuestA as QuestAScript).GetListOfMarkers() EndFunction Link to comment Share on other sites More sharing options...
dylbill Posted October 12, 2020 Share Posted October 12, 2020 If script A is this Scriptname ScriptA extends Quest ObjectReference[] Property SpawnPoints AutoIn Script B do this Scriptname ScriptB extends Quest ScriptA Property ScriptARef Auto ;In the CK, choose the form that ScriptA is attached to Event SomeEvent() ScriptARef.SpawnPoints[0].SomeFunction() EndEvent Link to comment Share on other sites More sharing options...
cheejins Posted October 12, 2020 Author Share Posted October 12, 2020 If script A is this Scriptname ScriptA extends Quest ObjectReference[] Property SpawnPoints AutoIn Script B do this Scriptname ScriptB extends Quest ScriptA Property ScriptARef Auto ;In the CK, choose the form that ScriptA is attached to Event SomeEvent() ScriptARef.SpawnPoints[0].SomeFunction() EndEvent Thanks. This worked exactly how I needed it to. Link to comment Share on other sites More sharing options...
cheejins Posted October 12, 2020 Author Share Posted October 12, 2020 Several approaches. I assume your hanging your scripts off of a quest: (a1) In script A define your array as a property so it can be accessed remotely: Scriptname QuestAScript extends Quest ObjectReference[] Property ListOfMarkers Auto ;Need to create ListOfMarkers = New ObjectReference[0] ;Need to build ListOfMarkers.Add(Marker) (a2) In script B access the remote script, remembering its a pointer so any changes are actually on the remote array: Quest Property pQuestA Auto Const Mandatory Function GetArrayA() ObjectReference[] LocalArrayPointer = (pQuestA as QuestAScript).ListOfMarkers EndFunction (b1) Or in script A publish a function that exposes the array Scriptname QuestAScript extends Quest ObjectReference[] ListOfMarkers ObjectReference[] Function GetListOfMarkers() Return ListOfMarkers EndEvent (b2) In script B call the remote function Quest Property pQuestA Auto Const Mandatory Function MyFunction() ObjectReference[] LocalArrayPointer = (pQuestA as QuestAScript).GetListOfMarkers() EndFunction Thanks for the reply. I will definitely use these ways in the future. Link to comment Share on other sites More sharing options...
Recommended Posts