B
Boola
Guest
hello there,
so i need a help with piece of code there it is:
#####
randomize();
var n;
var i;
for (n=0; n<=9; n=n+1)
{
deck[n]=irandom_range(1,10);
for (i=n-1; i>=0; i=i-1)
{
if (deck[n]==deck)
{
deck[n]=irandom_range(1,10);
i=i+1;
}
}
}
//show in debug mode
for (n=0; n<=9; n=n+1)
{
show_debug_message("deck["+string(n)+"] = "+string(deck[n]));
}
######
this code should pick a random number from 1-10 and write it in 1d array deck[0-9].
if new number is the same as any number picked before it will reroll it and check again.
that's how it should work but it isn't... i spend a half day with it and nothing help.
there is result of one of process:
#####
deck[9] = 5
deck[8] = 6
deck[7] = 5
deck[6] = 9
deck[5] = 1
deck[4] = 2
deck[3] = 4
deck[2] = 10
deck[1] = 7
deck[0] = 8
#####
as you see deck[9] and deck[7] have the same value.
Thanks in advance
so i need a help with piece of code there it is:
#####
randomize();
var n;
var i;
for (n=0; n<=9; n=n+1)
{
deck[n]=irandom_range(1,10);
for (i=n-1; i>=0; i=i-1)
{
if (deck[n]==deck)
{
deck[n]=irandom_range(1,10);
i=i+1;
}
}
}
//show in debug mode
for (n=0; n<=9; n=n+1)
{
show_debug_message("deck["+string(n)+"] = "+string(deck[n]));
}
######
this code should pick a random number from 1-10 and write it in 1d array deck[0-9].
if new number is the same as any number picked before it will reroll it and check again.
that's how it should work but it isn't... i spend a half day with it and nothing help.
there is result of one of process:
#####
deck[9] = 5
deck[8] = 6
deck[7] = 5
deck[6] = 9
deck[5] = 1
deck[4] = 2
deck[3] = 4
deck[2] = 10
deck[1] = 7
deck[0] = 8
#####
as you see deck[9] and deck[7] have the same value.
Thanks in advance
Last edited by a moderator: