Hi,
hashtables make sense starting at 2 items having only five items is totally OK: I even use Hashtables for preferences and settings. It's always better than hardcoding these properties and values in the code or fsm themselves.
if using arrays, yes, use the same loop, because you must expect all arrays forming a table to be consistent, so same number of items, you delete an item only by its indexes and always on all arrays, you add items to all arrays as well, etc etc. And so you would then only use one loop to got through them.
Bye,
Jean
Thanks Jean, I had a look at using a hashtable, couldn't quite get it working because I dont fully understand which values I would need. All my 5 items are the same, except I've named them item1 - item5. I think I will have to take your expert advice though, because I've realised that because the player is taking out index 0 every time he picks an item, it shifts the other items up in the index, which then confuses my NPC and he goes for items that arent there.
I've even tried (for the player) removing the last index in the array on each pickup. This works because the index doesnt shift up, but again it confuses the NPC, because when say, item2 is picked, the item at the end of the index is removed which could be item4.
So I think hash tables are my only hope, but I dont know if I need to loop through one, or just set it up at the start, then loop through the array?
By the way, one more thing, if I set my global transition outside of the loop so the main loop isn't touched at all, it doesn't make any difference to my NPC picking the items. Items are removed, then added back in without a loop. So do I need a FOR loop? I only have one array, no temp ones and looking at the loop all I'm doing is getting the list and adding 1 to my count. I dont know what else I need to do to each gameobject as it iterates?
Sorry for the trouble and the really long thread, but I'm so close!
thanks for any help.