I have a 2 dimentional array that is rather large, 65536 in total size.
Its a 256x256 map of 0's and 1's. Don't worry about what its for, its not a level or anything like that.
In another language I could just miss out assigning the 0's so just the 1's exist, saving alot of unnecessary data being written in to RAM. You could then just check whether the queried array index has a value, in gml i'd expect something like:
or
But there doesnt seem to be a way of checking an undefined variable or array index like this in gml as far as I can see. This would really save a lot of unnecessary data being stored and is a standard in most languages so wonder what the solution would be in gml?
I have noticed in 2.3 that try catches were added which is great. You could use that like:
This will work but just seems a little overkill for a simple check like this, and wonder if its a little slow. Has anyone else got any experience with similar issues in gml?
Thanks in advance for any help
Its a 256x256 map of 0's and 1's. Don't worry about what its for, its not a level or anything like that.
In another language I could just miss out assigning the 0's so just the 1's exist, saving alot of unnecessary data being written in to RAM. You could then just check whether the queried array index has a value, in gml i'd expect something like:
Code:
exists = is_defined(someArray[220, 56]);
Code:
exists = (someArray[220, 56] == null);
I have noticed in 2.3 that try catches were added which is great. You could use that like:
GML:
try {
exists = someArray[220, 56];
}catch(e){
// doesnt exist
exists = 0;
}
Thanks in advance for any help
Last edited: