Jump to content

How can I delete 'None' entries from a formlist ?


Recommended Posts

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 by EagleFour
Link to comment
Share on other sites

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 Actor
If LoopActor == None

 

This works:

If ActorList.GetAt(intIndex) == None

I 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

  • Recently Browsing   0 members

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