I am making an array inventory in Godot. I have six null
elements. I first use int find(variant,int from 0)
to find the first null index. And then I use insert(position,variant)
to fill in that null index. But I found that it keeps finding the null
next to it and ends up filling them all. So, the result is a completely filled array. How do I make it fill the first found only once? Such as after I pick one item, one slot gets fill at a time.
Oh, I just realized I was also using
for i in my_array.size():
sorting func()
So, it loops the whole array and finds null and fills the whole array. I was thinking why theraot's code didn't work. Now figured out:)