Can't make turn based system work

I am trying to make a turned-based battle system for a game I am making, that is determined by RNG+that character’s speed, but I cannot get the system to choose how to pick an order that the enemies go in, I cannot even figure out how to assign the enemy to their initiative values, what in the world am I doing wrong

Script link: PlayCanvas | HTML5 Game Engine

Hey @Linkplayer ! Can you send your editor/ project link so I can take a look?

https://playcanvas.com/editor/scene/2112576

I saw this message right as I got onto my computer, here is the link to the project

Thanks, I’m in the car rn but I’ll look at it as soon as I can.

Ok, thx

I am pretty sure I need to take the initiative of both the ally characters and enemies(I am only doing 4 enemies max right now before trying 6 enemies max) and add them to a list, then order that list from biggest to smallest(I know how to do that, but it will be a bit hard to even get the enemies and allies on the same turn order) and one problem I just realized a bit ago is how to figure show which entities have the specific initiative they got, and turn that into the turn order

I do have the other 2 extra slimes that are not being used until I get the script working for 4 enemies, then I will adjust it for 6, and try the other 2 with it

Can you elaborate what you mean by

Also

Do you have a system made yet that isn’t working or do you not have a system at all?

  1. the initiative of the entities right now is: a random number between 1 and 20 to which that entity's speed(which is determined by the type of enemy it is, but for right now it is selected in the entities settings when you click that entity) for the forest slimes their speed is 5

  2. I have it so a list shows what order the slimes are:
    6 5(5 and 6 are not active yet)
    4 3
    2 1
    in the list the order of their initiatives is [1,2,3,4,5,6] (example [10,13,25,16,12,7]) but if I rearrange it by biggest to smallest, the order would be scrambled up(using the example it would be [25,16,13,12,10,7] which the order the enemies would go in would be [3,4,2,5,1,6] but how would I code it so it knows that it would be in that order) but I don’t know how to find which initiative go to which enemy(or ally once I code that)

That seems kinda complex. This might be a bit less complex:

  1. Make a variable for each slime for their initiative and another one for the order.
  2. set the initiative variable to the random 1-20 and add their speed
  3. use greater than or less land stuff to figure out if a slime goes before or after a different slime (maybe set all their order variables to 6 to start, then set it to the order # of the slime that is more than it -1)

I know that’s a lot, feel free to ask any questions.