Rex Rainbown inst_group sort by variable

Get help using Construct 2

Post » Thu Oct 15, 2015 3:00 am

Hi there, just a quick question for someone out there that might be in the know...

I'm using the master Rex Rainbows plugins to put multiple chess on a board. No issues there. I have an extra instgroup object taking each chess UID as created and storing it in order as created. I have the chess moving around the board now in this order group called "turnorder". I now want to take it a step further and sort the UID list in the instgroup object according to a variable called "initiative" to alter the turn order.

My question is as follows... Is there an easy way to sort the instgroup object uid group by each objects "initiative" variable? ? If so how??? Not all of the object uid's in the group are an instance of a single object. Or am I going about this wrong, should I be putting them into an array instead and sorting that way? It was so easy to pop the uid's into the instance group I was hoping I could go that way. I had a look at Rex's UID2PROPERTIES, I'm not sure if this would be useful to find the initiative variable to sort the instance group or whether it is strictly used for something else.

I have been thinking about this for a while and researching, I don't ask a question unless I'm stumped so I would really appreciate any hints or tips you experts have. Thanks so much for your time.

Dave
B
7
S
2
Posts: 12
Reputation: 551

Post » Thu Oct 15, 2015 4:32 pm

You will need to loop through your array (like for loopindex=0:array.Width ) and put the element into a new array called "sortedArray" then check the current loop initiative vs 0 and (sortedArray.Width-1) indices in the sortedArray then use Push (back or front; based on the initiative) to build the new sorted array.

Reference:
sorting-an-array_t67745
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,415
Reputation: 4,824

Post » Fri Oct 16, 2015 7:23 pm

Alrighty then, array it is, I've got it set up now ... Eventually I'm probably going to have to sort other information in the array anyways. That was the next logical step I was just curious if there was another method or shortcut using Rex's addons.. I don't like finding out there was an easier way after a lot of work... ;) Thanks so much for taking the time out to respond to me, I really appreciate it. Love your game idea too, have checked it out.. Reminds me a bit of a couple games I own, SW rebellion and galactic civilizations from the screenshots so exciting.
B
7
S
2
Posts: 12
Reputation: 551

Post » Mon Oct 19, 2015 1:47 pm

Thanks, we are patterning it off of a combination of Master of Orion II/GalCiv and Lord of Ultima, with a number of new mechanics (like fully fiat currencies and sovereign debt markets).

I am actually going to be using the Array.Pop soon to make non-repeating random star name generation. Except that I am doing it in Java, but the same idea applies.
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,415
Reputation: 4,824


Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot] and 9 guests