playMaker

Author Topic: Need Help About Array [SOLVED]  (Read 3587 times)

keitaro3660

  • Playmaker Newbie
  • *
  • Posts: 16
Need Help About Array [SOLVED]
« on: April 26, 2015, 01:17:37 AM »
Hello, please help me.
I want to make this kind logic :

There's 3 variable.
Player will increase 1 (or three if they want) variable.

Then i must check WHICH ONE of the 3 variable that have largest value, not just take the value, but i want to know WHICH variable is that.

There's Array List Get Max Float, but it only take the value...
I need to know which float VARIABLE that has that Max Value.
Can you help me?? what should i do? really confuse about this.
« Last Edit: April 29, 2015, 12:22:30 AM by keitaro3660 »

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Need Help About Array
« Reply #1 on: April 26, 2015, 02:23:31 AM »
I might be misunderstanding you but it sounds like you need to use hash tables-

You could have one hash table with String Variables for the Name
And another hash table with the float Variables for the values

Give them both the same "key" then retrieve them by that key
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

keitaro3660

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Need Help About Array
« Reply #2 on: April 26, 2015, 05:04:53 AM »
I might be misunderstanding you but it sounds like you need to use hash tables-

You could have one hash table with String Variables for the Name
And another hash table with the float Variables for the values

Give them both the same "key" then retrieve them by that key
wow never try hash table before (i just instaled arraymaker addon 1 hour ago)
okay i'll try it, thank you for help:D

keitaro3660

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Need Help About Array
« Reply #3 on: April 26, 2015, 05:12:47 PM »
I might be misunderstanding you but it sounds like you need to use hash tables-

You could have one hash table with String Variables for the Name
And another hash table with the float Variables for the values

Give them both the same "key" then retrieve them by that key
okay so i already learn and use that hash table.
looks like this is the solution.
but i still don't know how to get the logic correctly, and still not understand correctly what you mean.
(or you mean i should make 2 hash table? is the reference different?)

is there a "Check highest Value" feature in Hash Table?
example of my current hash table

keyName1 = 20
keyName2 = 1
keyName3 = 40

2 question for this :

1. any idea how i can take my "keyName3" (because it has the biggest value) and store "that key name that has biggest value" to [string value]?
2. for hash table problem solving, is there usually only use hash table or use array too?

anyone want to help is welcome, please
« Last Edit: April 26, 2015, 05:22:31 PM by keitaro3660 »

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Need Help About Array
« Reply #4 on: April 27, 2015, 06:29:29 AM »
I made an example prefab that is attached-

Maybe not the best way but I'm not awake yet  :)

So what I did was create the two hash tables- one for strings and one for floats- then I made an array and sent the floats from the float hash in that array- then I looked for the biggest value- stored that value then search the float hash table for that value- once I got that then I got its key and matched the key from the string hash giving us the string var we wanted-

hope that helps
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

keitaro3660

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Need Help About Array
« Reply #5 on: April 28, 2015, 03:31:26 AM »
I made an example prefab that is attached-

Maybe not the best way but I'm not awake yet  :)

So what I did was create the two hash tables- one for strings and one for floats- then I made an array and sent the floats from the float hash in that array- then I looked for the biggest value- stored that value then search the float hash table for that value- once I got that then I got its key and matched the key from the string hash giving us the string var we wanted-

hope that helps
okay thank you for the help and prefab, i'll test it tonight :D

keitaro3660

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Need Help About Array
« Reply #6 on: April 29, 2015, 12:22:11 AM »
helloooowww
i just test it now (actually, your prefab export is not working, i can't open it)

luckily, your step by step explanation is so clear that i can make it my own
wooow, i little bit understands it now XD
but to get this result, it's really have quite long step, lol

but the result is fantastic, thank you very much for helping!! :D
now i can move my project forward again :D

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Need Help About Array [SOLVED]
« Reply #7 on: April 29, 2015, 08:11:36 AM »
Glad it helped!  :)
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!