# random numbers no duplicates zero always last!

0 favourites
• 10 posts
From the Asset Store
“Zero Numbers” is a logic game. Game with Source-Code (Construct 3 / .c3p) + HTML5 Exported
• Hi

My eyes are strained and head aches...

I have this piece of random number with no duplicates code in another project... it works BUT ZERO is ALWAYS last!

What am i missing or should i do?

many thanks for any help that can be given

dropbox.com/sh/rtf1ilgtg5mnrhg/A4i7lG7zV2

• Would you save as .capx? we prefer to download one file

• sorry new here...

many thanks

D

• Change "while i <= Array.width"

to "while i < Array.Width"

• Hi Vee41

Sadly I tried that before, that only gives me 10 numbers

i.e 1,2,3,4,5,6,7,8,9 and 10...

i need a total of 11 random non duplicating numbers including the Zero 0, but not always last... :(

I am probably missing something really simple...but?

D

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Well width of your array is only 10, no way you can fit 11 numbers into that :)

EDIT: So set your array width to 11, adjust the limit of numbers accordingly and do the change I described before.

• Vee

I am really really tired, so bear with me....

My knowledge is weak, so at the start i set array width to 11 (because i wanted 11 numbers), but i then got 12 numbers... ? which is 1 too many!

so to test this i set my array width to

2,i get a variable at 0,1,2 thus 3 numbers

5,i get a variable at 0,1,2,3,4 thus 6 numbers

10,i get a variable at 0,1,2,3,4,5,6,7,8,9,10 thus 11 numbers as i wish...

so i guess it starts at zero??????

I have added a text box to print out every number generated by the randomNumber code, it SHOWS zero's appearing YET not being accepted into the array...? it seems to wait until it has all the rest of the numbers then add a zero at the end.

dropbox.com/s/1noog3xyanq9iwz/screenshot.jpg

• Here you go: Fixed version

The array was initialized with 0's so it never gets randomed and random nubmer choosing stage. I initialize the array with -1 so it's a bit more intuitive to use now :)

• vee many many thanks

I did need the array to be 11 then, but fill it with something other than the numbers i needed, before refiling it with the randomNumbers , yes?

I think i understand, hahahahha

many thnaks again

D

• I did need the array to be 11 then, but fill it with something other than the numbers i needed, before refiling it with the randomNumbers , yes?

Exactly :)

Every value in array is 0 until you set it as something else, thus the randomizing part never randomed 0.

• 10 posts