Jump to content

Form List Index (does it change by itself?)


KingShelby

Recommended Posts

What I'm wondering is: If you have several items in a form list and you remove the "0" one will the list shorten up and place the "1" in the "0" place.

 

 

 

I have an empty form list

 

Items are added to the form list by script

 

The "0" First slot is checked and then if matched up the item in "0" spot is removed

 

 

-----

 

If I add several items at once to the form list will I be able to keep checking the "0" slot and removing it? or will the 1, 2, 3, 4, etc stay in the 1, 2, 3, 4, spots?

 

 

Link to comment
Share on other sites

A form list will flatten itself when forms are removed, just like an array.

To remove every item in a form list, you can do this:

while (ListGetCount MyFormList)
	ListRemoveNthForm MyFormList, 0
loop

However, that's only really useful if you want to do something with the processed forms:

ref rListRef

while (ListGetCount MyFormList)
	set rListRef to ListRemoveNthForm MyFormList, 0
	;do something with rListRef
loop

Otherwise, you might as well just:

ListClear MyFormList
Edited by Ladez
Link to comment
Share on other sites

Thanks for confirming that.

 

I was 99% sure it did, but when your tired and scripts start doing un-expected things sometimes you second guess things.

 

I have several scripts that check the form list and if the "0" form matches it gives the player the corresponding item and removes the "0" form. They (the scripts) keep checking and if "0" matches again it repeats .... removing the "0" form again. Several forms may be added at the same time, hence needing the list to shorten each time "0" is removed.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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