How do I create an rpg like initiative system

0 favourites
  • 7 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • i want to create a dnd like initiative order where the players score gets put into an array and then sorted by that number. i also want to attach the name to the number but when i do it sorts alpha-numerically rather than just numerically. if someone coould show me an example of how to do that i would greatly appreciate it, as i have been struggling with it for about a week.

  • Without a .capx we have to take some guesses. But assuming you have a 2D array where the scores in the array are at y=0, and names are at y=1, then the array should sort numerically by score, ascending. Otherwise please provide more information. Alternatively you could give each player an instance variables 'initiative' and then pick by highest value using the initiative variable.

  • codah thank you and i will try the alternate way, if that doesn't work then i will send the .capx if i can figure out how to do that. thank you once again

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • codah

    here is the .capx

  • Sorry had to step out for a bit. See if this helps

    These are ordered on-the-fly with a "For each .. order by". If you need to store the order you might want to go back to an array.

    I made a Family for the Sprites and put the 'initiative' variable on that. In my opinion ALWAYS put instance variables on a Family, not an object, for non-trivial objects.

    Similarly I made a Family for the Text objects. I gave each Family an 'ID' variable so that I could associate Sprite object with Text object. Could use containers but then I'd need to do it for each Sprite object type.

    Click the button and the Sprites are given an initiative as per your code, and displayed in order from highest to lowest inititative.

  • your problem is that you have 3 different sprite types, when you use pick instance with highest initiative your only doing it for the orange sprite..

    Add them to a family and set initiative as an instance variable for the family...

    Check the capx..

  • thank you both for replying, as both of your corrections are working the way i need them to. thank you once again

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)