Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: LeDisciple on March 16, 2019, 10:17:12 PM

Title: SORT ARRAY (WITH PICTURES AND MORE EXPLICIT) [SOLVED]
Post by: LeDisciple on March 16, 2019, 10:17:12 PM
hi,

first of all I try to help myself with that package from DjayDino:
http://hutonggames.com/playmakerforum/index.php?topic=10906.0 (http://hutonggames.com/playmakerforum/index.php?topic=10906.0)

here the pics from the setup:
(https://i.imgur.com/RT4D1rl.jpg)

(https://i.imgur.com/9UYbXv4.jpg)

(https://i.imgur.com/YgIyzzq.jpg)

I want an array list to be sorted by INT (already inside a GO )....and put the associated GO in a separated list than the random one
before sorting I extract and put INT and GO (game object)in separated arraylists...

so before sorted : INT array was like 0,1,2,2,0,1,1,0,0,2 for each GO. And that GO array was like:SO,MT,HT,MT,CT,MO,CT,MT,MO,MT
(https://i.imgur.com/s86azOj.jpg)

and then I sorted INT... Sorting was OK for INT:0000111222

(https://i.imgur.com/gYDOe6h.jpg)

But the "ArrayList Get" GO isn't:  its SO,SO,SO,SO,CT,CT,CT,MT,MT,MT

(https://i.imgur.com/q84sTeP.jpg)

I'ts like it take just the first 3 zeros from the unsorted int: Those associated with SO CT and MT...
 
HOW TO GET THE GO SORTED WITH HIS PROPER INT?

Thanks a lot ☺
Title: Re: SORT ARRAY
Post by: djaydino on March 17, 2019, 08:03:13 PM
Hi.
Yeah that's an old sample that has issues when same score.

This tutorial has a different approach, its using standard array but principal is the same for array list :


I will update that post of other people.

You can find the sample in my asset
Title: Re: SORT ARRAY (WITH PICTURES AND MORE EXPLICIT) [SOLVED]
Post by: LeDisciple on March 20, 2019, 09:34:43 PM
Hi,

I resolved it by myself.... I loved Arraymaker because there is a lot of actions available.... so here what i've done: (I put here only updated screenshots from previous ones)

1- I set the name of the game object by its own INT... Inject the index to a variable inside the game object ...

(https://i.imgur.com/G59hRzA.jpg)

2- Increment Index variable...

(https://i.imgur.com/Z3Wodpw.jpg)

3- Now with GO named by their own extracted INT variable, I can sort them...

(https://i.imgur.com/HZlaxRv.jpg)

4- With injected Index, I got them and look for INDEX inside my array where AI & Player Characters aren't sorted to see wich one will start the battle...

(https://i.imgur.com/fz5UZYu.jpg)

5- And that's it!! Here on the left we see (under ENNEMY HASH ARRAY) the process of renaming random created GO by their own random INT variable...

(https://i.imgur.com/XPqVR9c.jpg)

And here the turn-based waiting list done...

(https://i.imgur.com/xbGJJrH.jpg)

I know it's not perfect for now but it works to achieve what I needed.  ;D