Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hello, I just purchased this and tried to run it on GMS2 and am getting an error "index was outside the bounds of the array." Please help!

I'll check it out and see if I can narrow it down. Did you use the GMS2 source file or import the GMS1 source? I've seen a similar case for another project where import changes made the GMS2 source break but importing the GMS1 source solved the problem.

(1 edit)

I used the GMS2 source file, will try GMS1. (edit) Just tried this but I'm using a Mac and can only open GMS2 source file :/

Aw :/

Could you post the entire error message? Maybe there's some other clues in it (like WHICH array is out of bounds)

Also, did you try updating the player_score script? When investigating I found an error where it uses the wrong variables in two places, it worked in previous versions. You could try updating that and see if it solves the problem (it's a really small change)

Instead of this:

effect_spawn_textpopup(x,y,        ....

It should be this:

effect_spawn_textpopup(argument0,argument1,   ...

The error message only says "Index was outside the bounds of the array." I checked the player_score script and it was already like this:

effect_spawn_textpopup(argument0,argument1,   ...

I did some more investigations and found a thing in the GMS2 release notes: (this post). Seems to be broken in runtime 2.1.4.218, worked in runtime 2.1.5.246, and it works for me in runtime 2.2.0.258... what's your GMS2 runtime version?

From what I gather there's an issue where valid GML becomes invalid C++/JavaScript code sometimes when a single GML statement becomes multiple instructions when parsed, which sounds like a nightmare to track down :/

(Since 2.0.3.56 there's also an option to carry on and collect all errors that's possible before ending a compilation, it might be helpful in finding the resource that causes this to happen... perhaps?)

The issue mentioned in the GMC topic refers to an issue with for loops whose first statement isn't a variable assignment causing this error, I went through all for loops in the engine and none of them has it... only suspect thing is compatibility script __global_object_depths() having a "var i = 0" assignment, not sure if that would be a candidate with vars behaving different from ordinary variables? (The solution if this is the case would be moving the "var i" part outside the loop and then do a normal "i = 0" inside the for loop).

Geez, GMS2 still kinda feels like it's in beta sometimes :/

I'm using runtime 2.2.0.258 I tried changing "var i = 0" but I think I'm doing it wrong because I'm getting  an "unexpected syntax error"


this is how it looked before I changed it: 

// create another array that has the correct entries
var len = array_length_1d(global.__objectDepths);
global.__objectID2Depth = [];
for( var i=0; i<len; ++i ) {
var objID = asset_get_index( global.__objectNames[i] );
if (objID >= 0) {
global.__objectID2Depth[ objID ] = global.__objectDepths[i];
} // end if
} // end for


and this is after trying to do what you suggested:

// create another array that has the correct entries
var len = array_length_1d(global.__objectDepths);
global.__objectID2Depth = [];
for var i( i=0; i<len; ++i ) {
var objID = asset_get_index( global.__objectNames[i] );
if (objID >= 0) {
global.__objectID2Depth[ objID ] = global.__objectDepths[i];
} // end if
} // end for


sorry for being a pain, new to GMS2 really appreciate you trying to help.

Yeah, that's an actual syntax error... the correct version would be this:

var i;
for( i=0; i<len; ++i ) {

But yeah, this is weird... if we're using the exact same runtime to load the exact same file, we should get the same results. (You're using the v1.1 version of the GMS2 source, right?). Maybe it's time to contact Yoyo support about it...

There's one more thing we could try first, though... I'll try importing the GMS1 1.1 source file in the latest version of GMS2 and upload that as a GMS2 1.2 source file, and if there's any issues with the compatibility scripts that should hopefully be resolved by that.

Uploaded a new "Source Code (GMS2) (v1.2)" file which is freshly imported from the GMS1 source in the latest GMS2 runtime, please try that out and see if it solves the problem (it compiles and runs just fine for me, but then again so did all of the other versions...).

YES! Finally lol thank you so much, it works great :)

Awesome, glad to hear that! I suppose I'll go hide the outdated versions now so they don't trip any more people up...

Tried importing the GMS2 version in GMS2.2.0.343 and it had one error, there's a mistake in player_score (Scripts-->Gameplay-->Player-->Score Lives Etc) where it uses the calling instance's x/y instead of argument0/argument1. The body of the script should look like this, then it compiled fine for me:

if(argument3 && argument2 > 8000){
    global.playerlives++
    effect_spawn_textpopup(argument0,argument1,"1UP",c_lime,c_teal,font_retro)
}
else{
    global.playerscore += argument2
    effect_spawn_textpopup(argument0,argument1,string(argument2),c_white,c_black,font_narrow)
}
(Alternatively you could use argument[2] instead of argument2 and so on for the other arguments, this might be why you get an array index error)


If this doesn't solve the problem for you, could you please copypaste the entire error message? Usually it hints at where the error occurs.

the player_score already looks identical to the one you just sent. the error message only says "GameMaker: Studio AssetCompiler encountered a problem. Index was outside of bounds of the array." Then, at the bottom of the Output log it says:

/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono exited with non-zero status (82)

elapsed time 00:01:25.4687960s for command "/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono" /Users/Shared/GameMakerStudio2/Cache/runtimes/runtime-2.2.0.258/bin/Igor.exe -options="/var/folders/w4/215d0gjj3b7f5sql711p01jr0000gn/GameMakerStudio2/GMS2TEMP/build.bff"  -- Mac Run started at 11/03/2018 19:35:20
FAILED: Run Program Complete



p.s. let me know if you'd rather communicate via e-mail or whatever's easier