hi!
I have a problem with variables and random scenes.
My game has a series of indexes in a variable containing my scenes (it’s like a maze). at each scene, I want to remove the index so as not to fall back on the same scene.
I believe that “remove variable at index” will work but not:
when I remove the index, it removes all the indexes above my scene! and not only this one.
(For example, I want to remove index 8, and all indexes above 8 are removed, and not only the 8th)
I’m pretty sure it’s simpler but i don’t get it.
Thanks for the replies
Yes, this is the correct command to use for arrays.
If you are using arrays, remember that if you remove a variable at an index, all the other object at that index will shift forwards to fill the spot. If you have a remove at index without a condition that executed repeatedly, it will clear out the array.
If you’re still stuck, then give a screen snip of your events that remove the index.
Hi kaz, I am having a similar difficulty using “remove variable at index”.
May I ask what you mean about storing your index? How is that done and what does it do?
What I am trying to do is to model putting 26 letters in a hat and drawing them out randomly so as to not have any duplicate letters on the board. I think I am mostly there with this. I just need to be able to randomize the array. There is an add-on for that… but I can’t seem to make it work.
Don’t worry about randomising the array - use a random index instead, So, instead of Remove at index 0, use Remove at index Random(VariableChildCount(array_name)-1). As the array gets smaller, so does the random number generated.
Oh my goodness, that is absolutely brilliant! I have one last (well… hopefully) question for you. As I need not only to remove the index, I also need to display the letter that was in that index. I am thinking that I can store the value of the index generated by the random number to a variable that I’ll call “AnswerObject”. Then I can get the string of the global variable at index AnswerObject (I don’t know how to do this) and display that on the board and then “remove variable at index AnswerObject”. Any ideas?
Thank you! It works like a charm. Now, I just need to fold it into the scene and make it iterate. I can’t thank you enough. You’ve really gotten me over a big hurdle.