random numbers no duplicates zero always last!

Get help using Construct 2

Post » Tue Jan 22, 2013 12:00 pm


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

https://www.dropbox.com/sh/rtf1ilgtg5mnrhg/A4i7lG7zV2construct2dsjp2013-01-22 12:06:21
B
5
Posts: 14
Reputation: 453

Post » Tue Jan 22, 2013 12:45 pm

Would you save as .capx? we prefer to download one file
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Tue Jan 22, 2013 12:54 pm

sorry new here...

https://www.dropbox.com/s/tdf4auara29znts/again.capx
many thanks
D
B
5
Posts: 14
Reputation: 453

Post » Tue Jan 22, 2013 1:33 pm

Change "while i <= Array.width"
to "while i < Array.Width"
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Tue Jan 22, 2013 1:42 pm

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
B
5
Posts: 14
Reputation: 453

Post » Tue Jan 22, 2013 1:54 pm

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.vee412013-01-22 13:56:26
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Tue Jan 22, 2013 2:19 pm

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.

https://www.dropbox.com/s/1noog3xyanq9iwz/screenshot.jpg
B
5
Posts: 14
Reputation: 453

Post » Tue Jan 22, 2013 2:37 pm

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 :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Tue Jan 22, 2013 3:13 pm

vee many many thanks

i had to download r116 to see your capx

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
B
5
Posts: 14
Reputation: 453

Post » Tue Jan 22, 2013 3:24 pm

[QUOTE=construct2dsjp]
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?
[/QUOTE]

Exactly :)

Every value in array is 0 until you set it as something else, thus the randomizing part never randomed 0.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Next

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Google [Bot], imothep85, Marxally, Virpoja and 25 guests