• 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!

SOLVED [SOLVED] Game Doesn't Start in HTML5

A

Andything

Guest
Hello GameMaker folks! I'm new to coding and GM2 so apologies if I'm missing something. I'm troubleshooting my first game with DnD--everything works correctly in test mode, but when I run in HTML5 (any browser), I get stuck on a black screen and debug shows an error I'm having trouble understanding.

I searched the forum and found a couple people had a similar issue with the "physics_fixture_bind" function, but I'm not using that in my game.

I've copied the error I receive below exactly how it appears:

Code:
Unhandled Exception - Uncaught { message : "unable to convert undefined to a number", longMessage : "unable to convert undefined to a number", stacktrace : [ "function _xf("unable to convert undefined to a number")
", "function yyGetInt32([undefined])
", "function script_execute([instance], [instance], [undefined])
", "function gml_Object_obj_game_Step_0([instance], [instance])
", "function(769, 0, [instance], [instance])
", "function(769, 0, [instance], [instance])
", "function(769, 0)
", "function _Yc3()
", "function _uc3()
", "function _5c3(20635.356)
" ], script : "", line : -1 } in file undefined at line undefined
I gather that I'm executing a script somewhere (in obj_game?) that is missing parameters, but I've searched everywhere and can't seem to find what the error is referring to. I was hoping there might be info I'm missing that could point me in the right direction.

Thanks so much for your help!
 
A

Andything

Guest
Is this Game Maker 2.3? Did you declare a function in the script using the Declare Function action?
Appreciate the quick reply! Yes this is in Game Maker 2.3. I double checked my scripts and all of them do include the Declare Function action.
 
A

Andything

Guest
It's very possible--the tricky thing is that I'm using a number of scripts, some of which are using code from tutorials online, so I'm not sure which I understand all of them well enough to know which I'm implementing incorrectly. Is there a way to narrow it down using the info in the error? Does "obj_game_Step_0" mean that the issue is happening in the "obj_game" step event?
 
A

Andything

Guest
Weird, so I went through everything in the step event for obj_game and everything looks normal. I even disabled everything in that event to see if that solves it and I'm still getting that same error.

PS appreciate your patience figuring this out! So helpful to be able to talk this through
 
Last edited by a moderator:

Nidoking

Member
I believe that the problem is the script definition, but I would have to see the script definition to tell you what's wrong with it.
 
A

Andything

Guest
So at the moment the only script I'm executing in the obj_game step event is this one, which spawns falling leaves, so this may be the culprit? I converted this from DnD to post here. The variables are defined in the obj_game variable definition section. Works fine in local test mode but may be causing an issue in HTML5.

GML:
function scr_spawn_leaf()
{
    // If Variable
    if(spawn_leaf_timer <= 0)
    {
        // Assign Variable
        spawn_leaf_timer = spawn_leaf_initial;
    
        // Create Instance
        instance_create_layer(random_range(0, room_width), -16, "Leaves", obj_leaf);
    }

    // Else
    else
    {
        // Assign Variable
        spawn_leaf_timer += -1;
    }
}
 

Nidoking

Member
I don't see anything obviously wrong with it. If you remove both the script and the call(s) to the function, does the problem go away? It's just basic troubleshooting at this point.
 
A

Andything

Guest
Wow OK after a lot more troubleshooting I'm afraid the problem may extend to all scripts. I'll keep getting the same error until I remove all the Execute Script blocks that are running at the beginning of the game. But at that point the game is no longer playable.

Looking it up in the GM manual, is it possible this has something to do with the 2.3 changes?

Right now I'm calling the script with what appears to be the legacy formatting, where the script is the name of the function like below (converted from DnD).
GML:
script_execute(scr_spawn_leaf);
But the error seems to imply that it expects an argument to go along with it. I don't fully get how the new implementation is supposed to work though and whether it can be applied to the scripts I currently have.

Weirdly the same "undefined" error appears when I use "display_get_gui_width" as a parameter for drawing a square. Not sure if that's related somehow. Other function calls seem to be working.
 
A

Andything

Guest
Ahaa, figured it out! Read up a bit more and realized I should be using Function Call rather than Execute Script... realizing now that's exactly what you said up top @Nidoking but I didn't grasp it at the time. Apologies for the runaround, you got it in 1! Cannot thank you enough for your help
 
Ahaa, figured it out! Read up a bit more and realized I should be using Function Call rather than Execute Script... realizing now that's exactly what you said up top @Nidoking but I didn't grasp it at the time. Apologies for the runaround, you got it in 1! Cannot thank you enough for your help
How does this work when using a state machine? I usually have:
GML:
//Step Event
script_execute(state);
 
ok I think I got it
instead of
GML:
//Step Event
script_execute(state)
I use
GML:
//Step Event
function state(){

}
EDIT:
well now the game is not crashing but the states are not getting executed.
 
Top