Changing to Random Scene while excluding previously beaten

Hi All, I would like to change to a random scene once it has been completed but exclude any scenes that have already been beaten. Changing to a random scene seems doable but I’m stumped when it comes to excluding completed scenes.

Thanks in advance!

A sort of bodged solution would be to have a scene variable scene, and then whenever the level is beaten you change the scene variable to 1, and if that variable is 1 you run the code that switches to a different scene, this way if your random chooser happens to pick a previously beaten level then it will just re-roll until it finds a new one. I’d imagine you could have a better solution using arrays/lists, but I’m not qualified to talk about those.

Create a global array named Scenes with all scenes names inside it. When selecting a random scene, simply set a variable index to Random(GlobalVariableChildCount(Scenes) - 1), change the to the scene VariableString(Scenes[Variable(index)]), and use the action “remove index from array” with as parameter Variable(index). Do it in that order, the scene change always awaits that the events finish executing before happening, but the remove index removes it instantly so you cannot access it anymore after.


Apologies, when setting the variable index - what action should I be using?

Set Global Variable.

Or have I misunderstood your confusion?

I thought that’s what it was although it doesn’t seem to be working for me. Have I possibly done something else incorrectly?


In the second and third actions, you’re referencing Variable(index). It should be GlobalVariable(index).

Similarly it should be GlobalVariableString(Scenes…) in the 2nd action, and global array variable Scenes in the 3rd action

Sorry if I’m being dense but I just cant get my head around this. Here is where I’m at.

Your variable named Scenes is a global variable, so you need to use the global variable equivalents in actions 2 & 3. As it stands in action 2, you’re accessing it like a scene variable. I can’t tell in action 3, because the event wording is identical for the global and scene function.

In action 2, modify it to “Change to scene GlobalVariableString(Scenes[…])”

For action 3, double click the action and confirm it’s for the global variable.