playMaker

Author Topic: [SOLVED] rank systeme with ArrayMaker ?  (Read 3984 times)

Loic Joint

  • Junior Playmaker
  • **
  • Posts: 76
[SOLVED] rank systeme with ArrayMaker ?
« on: August 03, 2012, 12:10:18 PM »
Hello,

I try to make a simple ranking system with ArrayMaker, containing names and scores, all sorted in ascending order.

After a day of research, I have not managed to inssert to Array Maker in both the name and score of characters (I think this is impossible as there is only one dimension in a Array List ?) to sort later with event...

Can you help me? I'm just not be on the right way with ArrayMaker to do this kind of thing?

Thank you verry much!
« Last Edit: August 07, 2012, 03:32:03 AM by Loic Joint »

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: rank systeme with ArrayMaker ?
« Reply #1 on: August 05, 2012, 02:15:10 AM »
I don't think I can be of too much help, as I am just now getting comfortable with ArrayMaker myself, but some of what you're trying to do is similar to the way I used it in my project.
Basically you'll need two arrayList components.  Just create both of them on one gameObject, then name one "scoreNames" and the other "scoreValue" in the Reference Name fields. 
Afterward you can retrieve the values from each via the index amount.

I don't know how to actually sort the lists, though JeanFabre can probably answer this quite easily.  If I were to take a guess, however, I know there are included actions for reordering the arrayLists (If I remember correctly). 

Loic Joint

  • Junior Playmaker
  • **
  • Posts: 76
Re: rank systeme with ArrayMaker ?
« Reply #2 on: August 07, 2012, 03:31:22 AM »
Thank you for your help artician,

I finally found a solution without using arrayMaker, but I think you were on the right way ^^

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: [SOLVED] rank systeme with ArrayMaker ?
« Reply #3 on: August 07, 2012, 05:58:44 AM »
Hi,

 Was away, sorry I could not reply earlier. I am glad you have something working, I'll explain however how this can be done in arrayMaker, even as is you can sort things out over several lists.

so in your case, the following set up will work very well:

Have a hashtable  containing the names as keys and scores as values.

"john" : 15
"bob" : 18
"Anna" : 12
"boris" : 6


to sort scores, create a an arrayList just for that sorting purpose, use the action "hashtable Values" to get all the scores from the hashtable "scores", sort that list

you get the following:

18
15
12
6

now, you can iterate on that list, find the according score


now, you simply iterate through that list, and found the corresponding key and feed that on your list.

 Does that make sense?

bye,

 Jean

Loic Joint

  • Junior Playmaker
  • **
  • Posts: 76
Re: [SOLVED] rank systeme with ArrayMaker ?
« Reply #4 on: August 07, 2012, 03:14:11 PM »
thank you jeanfabre;

do not worry for the late reply, I totally understand !

Thank you for this solution and detailed explanations, I understand all. It is very clear. If my version without arrayMaker is too heavy, I would do tests with this version, I would make good use ! ^^

Thank you again!

psypol

  • Playmaker Newbie
  • *
  • Posts: 39
Re: [SOLVED] rank systeme with ArrayMaker ?
« Reply #5 on: July 06, 2015, 05:44:54 PM »
Hello.

Im digging this topic because i want to achieve somthing similar.
By reading Jean's solution do i understand well that this implies that no
Player has the SAME score?

In case more than one person has the same score this system wont work right ?

Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: [SOLVED] rank systeme with ArrayMaker ?
« Reply #6 on: July 08, 2015, 08:00:30 AM »
Hi,

 it still works, only that the sorting amongst player with the same score isn't guaranteed, and it's perfectly fine actually.

"john" : 15
"bob" : 18
"Anna" : 18
"boris" : 6

will give

18
18
15
6

so ranking is preserved, john is third, not second. and anna and bob will be both firsts.

Bye,

 Jean