Maybe ive just been at it too long but im drawing a blank atm. I have actors that have an exposed variable that is a unique integer. how do i find that actor based on that parameter? in this case i have a sorted array with integers and i need to find the actors associated with any gaps in the array by that integer
You’ll have to search through all actors of the type you want and check their values.
If they’re all static assets that don’t get created or deleted, then you can store a map somewhere constant. This maps integers to actors. Ie 4 → MyGameActor02204 & 5 → MyGameActor10539
If you’re more specific with what you’re trying to do, I can offer a more tailored suggestion
Ok so i have an array of actors that are scrabble tiles that have a variable that is populated by what board space number they are on when they attach to it from 1 to 225. As tiles are put on the board during the turn they are added to a CurrentWord array of basic actor object references. I have used a shell sort to sort them ascending based on what board space they are attached to. This leaves gaps if the word uses letters already in play. i have a formula that determines if the word is in a row or column so for rows i know i need to search for the next number sequentially when a gap is hit and i know i need to add 15 if the word is in a column. The ultimate goal is to extract the string variable from the actor with that value and add it to CurrentWord so all letters are accounted for when checking against the dictionary.
I guess i can get all actors of class and then loop through until i hit an actor with that value and then branch to an insert function for the CurrentWord array.
This should work i guess since i can just run the shell sort again i dont need to bother with inserting into any particular position. still need to figure out how to automatically generate a list of the tiles to check though. i need to step through and check tiles before and after the min and max of my array and then check again if it finds something until it hits an empty space and then repeat for letters at the end of the word.
On a sorted array you could try using binary search to get index of equal value:

You can also modify it to get low and high index to insert in the gaps:

Should be faster than sorting the array again.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.