Thinking it through, I didn't explain it very well.
1. Spawn a sprite (box) per box spawner (done manually until I can set it to be completed by a function and timed) - there are 6 spawners.
2. Generate values for several variables of each box (weight, strength, capacity, item(s) inside, etc)
3. When the box is selected, must complete action with that box which then sets selected back to 0. Only one box can be selected=1 at a time.
4. While box is selected=1 and other boxes are spawned, the selected=1 shouldn't be destroyed.
Think of character entering shed, random # of boxes to explore, picks one to take, can't take another until the one selected has an action (drop, destroy, de-select). Can still look in other boxes but can't pick it up (select it).
I don't necessarily need to recreate/respawn the boxes as long as the values were reset by the trigger (button clicked) however the long-term plan is eventually a random amount of boxes be spawned instead of the 6 each time.
Did the explanation help some? As I wrote it, Project Zomboid comes to mind.
I like your coding as it's obviously cleaner than what I had and gives me something to test with what I'm trying to accomplish. I'll see if I can post a mock-up of the code shortly.
Well I still don’t fully understand how you want it to work. I’m guessing you have a box per spawner, and you can select a box. Then clicking a button will create/ recreate the boxes that aren’t selected.
Global number pickedBox=-1
On box clicked
— set pickedBox to box.uid
On spawn_button clicked
[negated] box: pick by uid pickedBox
— box: destroy
On spawn_button clicked
[negated] spawner: overlaps box
— spawned: spawn box
If you set it up in the layout so each spawned has an overlapping box to begin with then the last two events could be merged into
on spawn_button clicked
[negated] box: pick by uid pickedBox
Spawner:overlaps box
— box: destroy
— spawner: spawn box
But then I wonder if we need to even recreate the boxes at all.
Again that’s why I don’t think I fully understand fully what exactly you wanted it to do.