EagleFour Posted April 3, 2022 Share Posted April 3, 2022 (edited) Hello, I have an Actor Formlist that I want to clean up.There are three entries.1.the first with an Actor Ref.2.The second one returns a 'None' entry (the Actor does not exist anymore).3.Also None, because the Actor no longer exists.How can I clean up the list so that only the first entry is in the list and I also get the correct length of 1 via GetSize()?If I try to delete the None entries via Formlist.RemoveAddedForm(None), they still remain in the list and i get a length of 3. Of Course,I can cache the list in an array, delete the formlist and then rebuild it, but it can't be that the formlist functions have no way to delete such 'empty' entries. Edited April 3, 2022 by EagleFour Link to comment Share on other sites More sharing options...
LarannKiar Posted April 3, 2022 Share Posted April 3, 2022 Try this: Int Index = MyFormList.GetSize() While Index >= 0 Actor LoopActor = MyFormList.GetAt(Index) as Actor If LoopActor == None MyFormList.RemoveAddedForm(LoopActor) EndIf Index = Index - 1 EndWhile Link to comment Share on other sites More sharing options...
EagleFour Posted April 4, 2022 Author Share Posted April 4, 2022 Unfortunately does not work. None' entries are retained.The problem seems to be that 'None' entries cannot be cast as Actor.Therefore this does not work: Actor LoopActor = MyFormList.GetAt(Index) as ActorIf LoopActor == None This works:If ActorList.GetAt(intIndex) == NoneI have now solved it like this: int intIndex = 0 Actor[] ActorList_temp = new Actor[ActorList.GetSize()] int intCounter = 0 While intIndex < ActorList.GetSize() Actor Aggressor_Victim = ActorList.GetAt(intIndex) as Actor If ActorList.GetAt(intIndex) != None ActorList_temp[intCounter] = Aggressor_Victim intCounter +=1 EndIf intIndex +=1 EndWhile intIndex = 0 ActorList.Revert() while intIndex < intCounter ActorList.AddForm(ActorList_temp[intIndex]) intIndex +=1 EndWhile Link to comment Share on other sites More sharing options...
Recommended Posts