• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Cleaning up multiple instances with ds_grids (correct use of self?)

trippity

Member
Hi all,

I have a number of instances that create a ds-grid when interacted with. In the cleanup event I have:
GML:
ds_grid_destroy(self.grid_test);
To destroy the grid when that specific object is destroyed. Is this the correct use of self?
 

Nidoking

Member
Is this the correct use of self?
It is if you have a local variable also called grid_test and you need to deconflict them. By which I mean the best practice is not to name two variables in different types of scopes the same. Here, you don't need to say "self" because each instance knows which grid_test it has, and if you're in a situation where you would need to say "self dot" anything, you should rename variables so that you don't need self dot.
 
Top