playMaker

Author Topic: Check if items are in Hash Table or Array  (Read 2245 times)

HAIRGROW

  • Playmaker Newbie
  • *
  • Posts: 24
Check if items are in Hash Table or Array
« on: April 02, 2014, 04:07:03 PM »
Hi, this is my first time posting to the forum, so I hope I'm asking this in the right place. Anyways, I'm learning how to use Array Lists and Hash Tables and was wondering, what's a good way to check if all items are contained in the List/Table. I've looked at the example Inventory scene provided by Array Maker and it's helped a lot, but I can't determine the best way to check if all items have been placed in the Inventory. I see there's a Hash Table Contain Values action, but I don't know how to use it to check for multiple items and then execute another action once all items are found.

I thought about creating a series of Bool Values which are set to True once the item has been added, and then check if All Bool Values are true and then go from there. But if there's more efficient way to check for these item's then I would rather do that. Any help with this would be greatly appreciated.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Check if items are in Hash Table or Array
« Reply #1 on: April 03, 2014, 01:09:03 AM »
Hi,

 Can you be a bit more precise? "ALL" items? typically, how do you know the "all", would you have another list with all possible items? maybe it's simply a matter of checking the size of the array ( if you know you have 10 items, and the array count is 10, then all of them are there, things like that).

bye,

 Jean

HAIRGROW

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Check if items are in Hash Table or Array
« Reply #2 on: April 03, 2014, 08:44:17 PM »
Thanks for reply. For "All Items" I mean there's a finite number of objects to collect. Based on the Inventory example, I do have a second list of all possible objects. I never thought about checking the size of the array. To do this, I assume I would used the Hash Table Count and then compare the results? I guess I was thinking there was a more secure way of checking if all items were contained in the list. As as in checking for them by name. I thought about checking for them by their keys in the Hash Table, which I believe is the UID in the Inventory scene, but that number would always change if the player checks the objects in and out from the inventory. Is there a way to compare two lists? Once again I appreciate the help. As an Artist, I'm not much of a programmer, but with Play Maker I can really make things happen.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Check if items are in Hash Table or Array
« Reply #3 on: April 04, 2014, 08:45:07 AM »
Hi,

 at some point you have rely on your logic within your system, and relying on the number of items seems fine by me, if you know as a fact that one can not add twice the same item on his inventory, and then it's safe to assume the the number of items   reflects the state of the inventory, else it should be considered a bug and fixed.

bye,

 Jean