Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Loic Joint 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!
-
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).
-
Thank you for your help artician,
I finally found a solution without using arrayMaker, but I think you were on the right way ^^
-
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
-
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!
-
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
-
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