Jump to content

TryToAddToFaction?


xcafe

Recommended Posts

So according to the CK wiki, TryToAddToFaction is a function you can use on a quest alias to add the filling actor to a faction.

However, when I try and do this, I get a compiler error; any suggestions?

 

My Script:

 

 

 

Function AddFac()
Int ListSize = CrowdREFList.GetSize()
          Int Index = 0
             While Index < ListSize
               Form REF = CrowdREFList.GetAt(Index)
                  If (REF as Actor)
                      (REF as Actor).TryToAddToFaction(NoCrowdFaction)                               
                       EndIf
                            Index += 1
                              EndWhile  
                                                                                
                                  EndFunction     

 

 

 

The Example Script:

BossAlias.TryToAddToFaction(BanditFaction)

The Compiler Error:

C:\Program Files (x86)\Steam\SteamApps\common\Skyrim\Data\scripts\source\CentralListScript.psc(211,37): TryToAddToFaction is not a function or does not exist

Sidenote: CrowdREFList (The formlist I'm pulling from) and NoCrowdFaction (The faction I'm trying to add to) are both defined as properties within the script, so that shouldn't be the problem. :confused:

Link to comment
Share on other sites

Scripting with aliases is something I am not too familiar myself. The examples on the wiki page make it look like as if the function were supposed to be run on a ReferenceAlias. As in, whatever it is you are calling it on would need to be a ReferenceAlias. You are currently casting the form in the FormList as an Actor, and the Actor script does not have that function. Fetching your ReferenceAliases as ReferenceAliases might help? Maybe? Also, assuming the small piece of script on the page is the actual function (this page --> http://www.creationkit.com/index.php?title=TryToAddToFaction_-_ReferenceAlias ) then you do not need to do any checks yourself (edit: oooops.... actually, maybe checking if the element actually can be cast as a ReferenceAlias). As in:

Function AddFac(FormList ReferenceAliasList, Faction FactionToAdd)
    If (ReferenceAliasList && FactionToAdd)
        Int i = ReferenceAliasList.GetSize()
        While (i > 0)
            i -= 1
            ReferenceAlias TempAlias = ReferenceAliasList.GetAt(i) as ReferenceAlias
            If (TempAlias)
                TempAlias.TryToAddToFaction(FactionToAdd)
            EndIf
        EndWhile
    EndIf
EndFunction

Regarding your first example (adding all actors in a FormList into a certain faction), you could also do it with just actors using AddToFaction: http://www.creationkit.com/index.php?title=AddToFaction_-_Actor

Function AddFac(FormList ActorList, Faction FactionToAdd)
    If (ActorList && FactionToAdd)
        Int i = ActorList.GetSize()
        While (i > 0)
            i -= 1
            Actor TempAct = ActorList.GetAt(i) as Actor
            If (TempAct)
                TempAct.AddToFaction(FactionToAdd)
            EndIf
        EndWhile
    EndIf
EndFunction

Hopefully that helps a bit. Merry Christmas, too! :thumbsup:

Edited by Contrathetix
Link to comment
Share on other sites

Scripting with aliases is something I am not too familiar myself. The examples on the wiki page make it look like as if the function were supposed to be run on a ReferenceAlias. As in, whatever it is you are calling it on would need to be a ReferenceAlias. You are currently casting the form in the FormList as an Actor, and the Actor script does not have that function. Fetching your ReferenceAliases as ReferenceAliases might help? Maybe? Also, assuming the small piece of script on the page is the actual function (this page --> http://www.creationkit.com/index.php?title=TryToAddToFaction_-_ReferenceAlias ) then you do not need to do any checks yourself (edit: oooops.... actually, maybe checking if the element actually can be cast as a ReferenceAlias). As in:

Function AddFac(FormList ReferenceAliasList, Faction FactionToAdd)
    If (ReferenceAliasList && FactionToAdd)
        Int i = ReferenceAliasList.GetSize()
        While (i > 0)
            i -= 1
            ReferenceAlias TempAlias = ReferenceAliasList.GetAt(i) as ReferenceAlias
            If (TempAlias)
                TempAlias.TryToAddToFaction(FactionToAdd)
            EndIf
        EndWhile
    EndIf
EndFunction

Regarding your first example (adding all actors in a FormList into a certain faction), you could also do it with just actors using AddToFaction: http://www.creationkit.com/index.php?title=AddToFaction_-_Actor

Function AddFac(FormList ActorList, Faction FactionToAdd)
    If (ActorList && FactionToAdd)
        Int i = ActorList.GetSize()
        While (i > 0)
            i -= 1
            Actor TempAct = ActorList.GetAt(i) as Actor
            If (TempAct)
                TempAct.AddToFaction(FactionToAdd)
            EndIf
        EndWhile
    EndIf
EndFunction

Hopefully that helps a bit. Merry Christmas, too! :thumbsup:

Awesome, thank you! Merry Christmas to you too! :laugh:

Link to comment
Share on other sites

  • Recently Browsing   0 members

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