-
Combing Loops, If/thens, indexes, and list ordering….
I can figure out if/thens and loops on their own, but combining them together into a single expression is something I can’t quite figure out.
I’m attempting to create a dynamic initiative tracker for a D&D podcast. I’ve gotten all of the expressions sorted out, except for one: Sort their initiative rolls (the number on the left) from highest to lowest. I know the method I want to use, but it’s the execution that I’m struggling with.
The method I’d like to use is fairly straight forward. I have N number of combatant layers above a null named “loopCount”. By referencing loopCount’s layer index, I’ll be able to dynamically determine the number of combatants, and thusly the number of loops I’ll need to execute. Each combatant layer will have a slider property called smallerNumbers. I’ll be taking each layer’s “initiativeRoll” slider property, and looping through the initiativeRoll property for every combatant layer. For every layer that this layer’s initiativeRoll property is larger than, increment this smallerNumbers’ value by 1. Once I know how many other rolls this layer’s initiative is larger than, I’ll just multiply the the smallerNumber result by some constant number, and add it to the layer’s Y position. Theoretically, this should have the list visually sorted in the composition… Possibly in reverse, but that’s a problem for later.
This method does mean that identical initiative rolls won’t ‘see’ each other and sort properly, so ideally I’d also like it to kick back an error notification if there’s duplicate initiative rolls.
It’s so frustrating to know what I want to do, but just not knowing the syntax to get it working how I want.