Quick Help

Posted by Siert on March 20, 2007, 8:23 p.m.

Okay I have a problem, I'm using arrays, but they are all copying each other, I set up two, then the third, but the first and second are always the same. I change the second, and it changes the third. Please help, and please don't remove this from the front page, I will when it's answered, thanks.

//create event

pieces[0,0] = 0

grid[0,0] = 0

variable_global_array2_set(pieces,0,0,9)

variable_global_array2_set(pieces,1,0,8)

variable_global_array2_set(pieces,2,0,10)

variable_global_array2_set(pieces,3,0,12)

variable_global_array2_set(pieces,4,0,11)

variable_global_array2_set(pieces,5,0,10)

//draw event

draw_text(355,280,string(variable_global_array2_get(grid,0,0)))

It displays 9.

Comments

noshenim 17 years, 8 months ago

post script/code?

Crane-ium 17 years, 8 months ago

AAAH! SHORT SHORT <b>SHORT</b> BLOG! REPORT REPORT REPORT!

…AHAHA! I got you there, I knew I'd trick you.

I'm not good with arrays, so have fun doing it yourself!

noshenim 17 years, 8 months ago

Have fun finding out that i need to see the code you used to help.

Polystyrene Man 17 years, 8 months ago

This is a situation where it would be really nice to see your code.

noshenim 17 years, 8 months ago

ok

not exactly what i thought you meant.

it should be displaying 0

ny other events/code?

if you're using global variables, it means that there's another thing using those variables.

draw_text(355,280,string(variable_global_array2_get(grid,0,0)))

is the same as

draw_text(355,280,string(global.grid[0,0]))

Polystyrene Man 17 years, 8 months ago

Looks like the problem is in the create event you've forgotten:

variable_global_array2_set(grid,0,0,x)

You haven't dealt with the grid array at all in the create event, just the pieces array.

Polystyrene Man 17 years, 8 months ago

Ah, I misunderstood the problem. Why not try doing this anyways:

variable_global_array2_set(grid,0,0,0)

noshenim 17 years, 8 months ago

(you have the grid array but not the global grid array)

Polystyrene Man 17 years, 8 months ago

Also, those (pieces and grid) look like local variables, so you should probably be using variable_local_array2_set

Siert 17 years, 8 months ago

Player: so i can just ditch the functions and use grid[a,b] since its all in one object? But why does it use the other array then. I'll have to see tomorrow if it works. Thanks!