Extract numbers from a specific array without repetition

How do I… extract numbers from a specific array without repetition?

I have 2 scene variables (they change from scene to scene):
Player1_Action (6, in this specific case);
Team1_Action (12).

I want to extract 6 random numbers that do not repeat among the 12 available. How do I proceed?

What is the actual result

I tried to do this, (creating an array from Team1_Action), but something is clearly wrong…

Thank you in advance for you help!

Something like this?

Okay, so now I have a “selectedNumbers” array of 6 numbers (2,5,6,7,9,11 for example) out of 12.
I have a counter for Team1_Actions (from 12 to 1), I want to trigger a Player Action everytime one of the selectedNumbers above is equal to the Team Action one (in the example it was fixed to 8, then 6, etc.).

How can I do it?

Thanks!


This extension has an action to shuffle arrays:
https://wiki.gdevelop.io/gdevelop5/extensions/array-tools/

1 Like

Thanks @davy, that will make the routine a bit more concise and probably more readable & understandable.

Use the extension @davy mentioned. It has an “Array has number” condition. This will do what you’re after.

Okay, thank you both of you!