scr_check_surrounding looks correct to me. Besides the out of range error that it can cause.
Here's why
say I have an array that is 5 by 5 grid (so the indexes are [0 to 4][0 to 4]
If we were to ask any number that is not within that we will be looking into an index that does not exist.
if scr_check_surrounding gets called with for example [0][0]
Both offset value's will be -1.
So how do fix this? if we can see that one of the offsets is -1 we need to skip the index from testing.
if x offset is larger then the width or the y offset is larger then the height we also need the skip the index from testing. Once that is in scr_check_surrounding shouldn't cause this error anymore.
scr_remove_same is almost correct, the only thing you are doing wrong is the variable you are referencing.
We've stored our values in the variable: global.IndexFilled not global.index_filled
Ohh also, a thing I forgot to state before, if the bubble is getting deleted, we'll also need to update global.IndexFilled.
The index will need to become -1.
also just as a side-note checking if a Boolean is true or false makes no sense. If statements content occur if the conditional is true.
The reason we may do
Is because someInteger == 4 will fall down to a Boolean, either that is true, or it's false.
If we already are a Boolean we can do these two things to differentiate between true and false:
Code:
if(Boolean){
//do stuff when Boolean is true
}
if(!Boolean){
//do stuff if Boolean is false
}
Now you want to use that bubble_fixed object. Thats perfectly fine but you do need to keep in mind what you are storing inside global.IndexFilled.
It should be filled with -1 and the actual in game instances. You are filling it with self (and yes self is gml's this), Then creating something else,
Then deleting self.
So the instance we just stored has been deleted.
So swap these two lines
Code:
global.IndexFilled[(x-80) div 32, (y-40) div 32] = self; //equivalent of "this" which you suggested?
bubble = instance_create(x,y,obj_bubble_fixed); //this line needs to be below x= and y= so the obj snaps correctly to the grid
and change self to bubble.
This occurs twice I believe. ( in the code you posted).
Now on the two errors. I've elaborated on the first one.
But so you can debug these kinds of issues on your own on the future.
The line we care about first is this one:
Code:
Push :: Execution Error - Variable Index [5,8] out of range [15,8] - -5.IndexFilled(100000,160008)
So here gml is telling you that an out of range error occurred. This means again that you tried to access an part of the array that was never internalized.
Look at the above part to fix the issue
On the second one
Code:
Array index must be +'ve at gml_Script_scr_check_surrounding (line 20) - inst = (global.IndexFilled[x_index_checking, y_index_checking])
This to me reads that array indexes must be positive. -1 or smaller shouldn't ever be called at the lowest 0.
This is happening due to two things.
Recursion calls and the double for loop thats checking the surrounding indexes.
It's perfectly fine to post Skype ID's. I just kinda hate Skype since recently, it's just been really bad performance wise, main reason I'd be willing to budge is to use the screen share feature. Otherwise might as well use discord. If not the GMC discord one that we just make to use for this.
My Skype ID is find-able on my account on the GMC and for good measure it's TDSrock.