How do I get position of items in itemlist?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By cppgraphics

I want to get an individual items position but can’t seem to work it out.

Do you mean you want the index of an item in the list? Or do you have a list of nodes and you want to get their position property?

scrubswithnosleeves | 2022-08-06 19:26

Going by the documentation I think you’re going to have to use a For Loop searching for the string you’re looking for which returns the position of the iterator.

var idx: int = GetPositionInItemList(searchValue, itemList)

func GetPositionInItemList(searchVal: string, _itemList: ItemList) -> int:
for i in _itemList.get_item_count():
     if _itemList.get_item_text(i) == searchVal:
          return i

dacess123 | 2022-08-12 19:28