xcafe Posted December 24, 2016 Share Posted December 24, 2016 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 More sharing options...
Surilindur Posted December 25, 2016 Share Posted December 25, 2016 (edited) 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 EndFunctionRegarding 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 EndFunctionHopefully that helps a bit. Merry Christmas, too! :thumbsup: Edited December 25, 2016 by Contrathetix Link to comment Share on other sites More sharing options...
xcafe Posted December 25, 2016 Author Share Posted December 25, 2016 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 EndFunctionRegarding 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 EndFunctionHopefully that helps a bit. Merry Christmas, too! :thumbsup:Awesome, thank you! Merry Christmas to you too! :laugh: Link to comment Share on other sites More sharing options...
Surilindur Posted December 25, 2016 Share Posted December 25, 2016 (edited) No problem, happy to help. Also happy new year, that one is coming as well. :D Edited December 26, 2016 by Contrathetix Link to comment Share on other sites More sharing options...
Recommended Posts