Jump to content

Referring to aliases across many quests


Recommended Posts

In the mod I’m working on I have a primary quest that has a script containing function F(). In F() I need to reference aliases with the same name and function across many vanilla quests.

quest 0 - aliasX

quest 1 - aliasX

Etc.

I’ll be calling F() from each of these quests (unless there’s a better way) so could pass on which quest via F(0), F(1) etc. but I don’t understand how to avoid the hideousness of having a property for each quest alias in my primary quest script. Is there something I can do with an array to make this more efficient ?

Link to comment
Share on other sites

Use a parameter in your function that takes the reference alias from the given quest.

i.e. Function F(Quest Q, ReferenceAlias RA)

Thus, when you call your function from the other quest you can pass in the quest as well as the alias reference used on that particular quest.

It will theoretically work. I personally have not tried it.

Link to comment
Share on other sites

Thanks - I’m not understanding how it gets around having to declare properties in the script housing F() for each of those aliases smuggled in—eg if I have a search through a form list and I’m comparing the REF for each alias to items in that formlist, that would require a massive list of properties Alias1, Alias2…Alias99 each of which would point to the Alias’ in quest1, quest2…quest99 in my primary quest. Sorry if I misunderstand.

Link to comment
Share on other sites

If the name of the reference alias is the same in all quests, you can also use thequest.getAliasByName( "alias name").  You'd still need to pass "thequest" as a parameter to the function.

If you want to use indices, like you suggested, instead of passing the quest as a parameter (or the reference alias), you can use an array property:

Quest[] property questArray auto
ReferenceAlias[] property aliasArray auto

You can then fill the arrays in the CK, or with papyrus...

Note that in referring to another quest's aliases using local properties (or array properties), you may run into trouble.  The order in which the quests are initialized is not always obvious and there are situations where your initializer may try to fill the local property holding the foreign alias before the foreign quest is initialized.  In those situations, your reference alias property will be initialized to None.

Link to comment
Share on other sites

5 hours ago, csbx said:

Thanks - I’m not understanding how it gets around having to declare properties in the script housing F() for each of those aliases smuggled in—eg if I have a search through a form list and I’m comparing the REF for each alias to items in that formlist, that would require a massive list of properties Alias1, Alias2…Alias99 each of which would point to the Alias’ in quest1, quest2…quest99 in my primary quest. Sorry if I misunderstand.

When you write a function, you can establish what parameters are passed into that function.  The function will then work with those parameters. 

FormList Property myList Auto

Function myF(Form myForm)
  Int index = myList.Find(myForm)
  If index != -1
    ;do something
  EndIf
EndFunction

And to trigger the function

NameOfControllerScript Property myCS Auto
ReferenceAlias Property myAlias Auto

;inside function or event
myCS.myF(myAlias.GetReference() as Form)

 

But you did mention vanilla quests (aka stock quests) and for compatibility reasons may not wish to modify any scripts and / or records associated with said stock quests.

Without specifics on what you are doing and examples of what you are doing, we can only speculate in possibilities.

***************

If you are willing to use or are using SKSE the following might be a possibility but may need work to fit within your needs (it is theoretical untested code):

FormList Property myItems Auto
Quest[] Property myQArray Auto
String[] Property myANames Auto
;index match the quest and string arrays

Function myF()
  Int ix = myQArray.length
  While ix >= 0
    ix -= 1
    If myQArray[ix].IsRunning()
      Int idx = myItems.Find(myQArray[ix].GetAliasByName(myANames[ix]).GetReference())
      If idx != -1 ;reference item exists and is in the array
        ;do something
      EndIf
    EndIf
  EndWhile
EndFunction

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...