Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: mitchelq on March 27, 2014, 03:43:30 PM

Title: Get the key of a hashtable by searching for a specific value [SOLVED]
Post by: mitchelq on March 27, 2014, 03:43:30 PM
Hello,

I'm trying to get the key of a hashtable by searching for a specific value, but I can't seem to find a way to do this.

I can do it the other way (by searching for a key and then getting the value of the key) but it seems impossible to get the key?

Example what I mean:
Keys / Values

enemy 1 / 10
enemy 2 / 15
enemy 3 / 12
enemy 4 / 8

I would like to get the highest number. I can get that by making an array of the values and sort it, but then I will still need to get the key to see which enemy it belongs to. The numbers/values do change every now and then.

Love to get some help on this.

Thanks in advance!

Best regards,

Mitchel
Title: Re: Get the key of a hashtable by searching for a specific value
Post by: mitchelq on March 28, 2014, 06:29:30 PM
I found a way to go around the problem.

I now create an array from my hashtable which I sort, revert en get the highest value from. After this I go through my hashtable with the get next action and store the value as a variable which I compare to my highest value. If it matches I use the key and if not go to the next.

Not completely the right solution, but for now it works. If anyone has a better solution I'm still happy to hear so.

Thanks,
Title: Re: Get the key of a hashtable by searching for a specific value [SOLVED]
Post by: jeanfabre on April 08, 2014, 08:05:34 AM
Hi,

It's all ok apart from the getting the key from the value on a hashtable. use "HashTableGetKeyFromValue" instead.

bye,

 Jean