dizietemblesssma Posted Saturday at 10:38 PM Share Posted Saturday at 10:38 PM I have a quest with a bazillion aliases, I have a script attached to each alias: Spoiler Scriptname dz_magazine_alias_clear extends ReferenceAlias ;;;designed to clear the alias once the objectreference is activated to prevent it reappearing as a quest objective if the item is dropped;;; ReferenceAlias[] Property my_array Auto Int Property my_objective Auto Event OnActivate(ObjectReference akActionRef) Self.Clear() debug.trace("DMR: magazine alias is now "+Self.GetReference()) dz_check_magazines() EndEvent Function dz_check_magazines() Quest my_quest = Self.GetOwningQuest() ;get the quest Int i = my_array.Length ;size of array Int j = 0 int count = 0 ;to count filled aliases While j < i If my_array[j].GetReference() ;is alias filled count += 1 EndIf j += 1 EndWhile If count == 0 ;if no filled aliases my_quest.SetObjectiveCompleted(my_objective) ;complete objective EndIf EndFunction I'm aware that the script may have deficiencies, but it's the referencing a pre-existing array that I wish to crack. Is there another approach that may be equivalent? diziet Link to comment Share on other sites More sharing options...
SKKmods Posted Saturday at 11:13 PM Share Posted Saturday at 11:13 PM Define and manage the array on a central quest attached script and get the alias scripts to access it via: ReferenceAlias[] myArray = (Self.GetOwningQuest() as myQuestScriptName).myArray OR even more elegant is to put all the logic in the central quest attached script function and call it from the alias scripts: (Self.GetOwningQuest() as myQuestScriptName).myFunction(thisReferenceAlias = Self) Link to comment Share on other sites More sharing options...
dizietemblesssma Posted Sunday at 06:13 PM Author Share Posted Sunday at 06:13 PM Okay, that's v. useful thankyou:) But no way to set the array as a property in the alias script? That way I can have the one script for all aliases but just change a property for some of them? diziet Link to comment Share on other sites More sharing options...
SKKmods Posted Sunday at 07:12 PM Share Posted Sunday at 07:12 PM Well yes you can do it that way if you are mad, but alias scripts calling alias scripts is not best practice: ReferenceAlias[] myArray = (Alias_otherReferenceAlias as otherReferenceAliasScriptName).myArray Shared data and functions is exactly what a central quest attached script is for. Link to comment Share on other sites More sharing options...
dizietemblesssma Posted Sunday at 08:44 PM Author Share Posted Sunday at 08:44 PM Ah, misunderstanding. I don't want to reference an alias script from another alias script. I want one alias script that is attached to all aliases. Originally I wanted to set the properties of that script to be different for some aliases and for that property to be one of the arrays defined as a property of the quest fragment. That way each alias has the same script but when the script runs it will operate on a specific array. It seems in my testing that setting an array in the properties dialogue only allows manually filling it. So I'm thinking that your suggestion of putting it in the main quest script makes sense, with a function to return a referencealias array according to a passed in string or int that is specified in the alias script and set by that alias script instance's properties: Scriptname dz_magazine_quest_script extends Quest ReferenceAlias[] Function dz_magazines_array(String array) If array == "005" Return refarray_005 EndIf EndFunction ReferenceAlias[] Property refarray_005 Auto Const ReferenceAlias[] Property refarray_anarchy Auto Const ReferenceAlias[] Property refarray_charo Auto Const and: Scriptname dz_magazine_alias_clear extends ReferenceAlias ;;;designed to clear the alias once the objectreference is activated to prevent it reappearing as a quest objective if the item is dropped;;; String Property array Auto Int Property my_objective Auto Event OnActivate(ObjectReference akActionRef) Self.Clear() debug.trace("DMR: magazine alias is now "+Self.GetReference()) dz_check_magazines() EndEvent Function dz_check_magazines() ReferenceAlias[] my_array = (Self.GetOwningQuest() As dz_magazine_quest_script).dz_magazines_array(array) Quest my_quest = Self.GetOwningQuest() ;get the quest Int i = my_array.Length ;size of array Int j = 0 int count = 0 ;to count filled aliases While j < i If my_array[j].GetReference() ;is alias filled count += 1 EndIf j += 1 EndWhile If count == 0 ;if no filled aliases my_quest.SetObjectiveCompleted(my_objective) ;complete objective EndIf EndFunction diziet Link to comment Share on other sites More sharing options...
Recommended Posts