How to stop repeating random number

Get help using Construct 2

Post » Thu Aug 03, 2017 5:27 pm

How i can stop repeating random number
I want random number but i don't want to repeat until all number covers
Image
B
63
S
39
G
42
Posts: 627
Reputation: 30,472

Post » Thu Aug 03, 2017 5:47 pm

Hello,

https://www.scirra.com/tutorials/315/ge ... duplicates

This was write the 1, June 2012.

Have a good day.
B
10
S
2
Posts: 35
Reputation: 680

Post » Thu Aug 03, 2017 6:47 pm

is their any other way without using arrays?
Image
B
63
S
39
G
42
Posts: 627
Reputation: 30,472

Post » Thu Aug 03, 2017 10:26 pm

If not to many numbers.....

Give an object an instance variable 'RndNr'.
Create instances during runtime (startup) and store values in 'RndNr' ...
Or ... create them in the layout editor and assign the values there to 'RndNr' ...
..... As you wish.
Mark them as picked with a boolean or destroy them. Say the boolean is named 'Used'.

Then.
Or :

System > Pick random instance (Object)
_____________action ... then number is in Object.RndNr
_____________destroy object

Or:
Is boolean (Object) instance variable set ('Used')
System > Pick random instance (Object)
_____________action ... then number is in Object.RndNr
_____________Set boolean 'Used' to true

Or: If you want to reset the cycle, using that boolean

Is boolean (Object) instance variable set ('Used')
_______Sub System > Pick random instance (Object)
_____________action ... then number is in Object.RndNr
_____________Set boolean 'Used' to true
Else
______Sub Pick all (Object)
____________action Set boolean 'Used' to FALSE
_________Sub System > Pick random instance (Object) <---- sub under the 'pick all' to start from that picklist
_______________action ... then number is in Object.RndNr
_______________Set boolean 'Used' to true


But, personal, i use and love the array way of doing this.
Or the perfect @blackhornet plugin
plugin-smart-random_t163624
B
33
S
18
G
27
Posts: 2,440
Reputation: 20,344

Post » Fri Aug 04, 2017 2:24 am

Casimir wrote:Hello,

https://www.scirra.com/tutorials/315/ge ... duplicates

This was write the 1, June 2012.

Have a good day.


in your tutorial both links are dead
Image
B
63
S
39
G
42
Posts: 627
Reputation: 30,472

Post » Fri Aug 04, 2017 10:32 am

@luckyrawatlucky You have everything in the tutorial i dont understand why you complain.

Programming and having a problem is the most fun thing.


Now the most of time if you search a little bit you can easely find informations.

-Tutorial
-Plugin

The plugin link that "99Instances2Go" post work pretty well.

Before posting here please try to make more search.


Have a really good day ! And have fun
B
10
S
2
Posts: 35
Reputation: 680

Post » Fri Aug 04, 2017 11:15 am

No i am not complaining
i am already following 99instance2go method
but i just want to see your capx for review
Image
B
63
S
39
G
42
Posts: 627
Reputation: 30,472


Return to How do I....?

Who is online

Users browsing this forum: davidbox, Mayfly, Yahoo [Bot], zulerf and 7 guests