Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

GMLive.gml

Livecoding for GameMaker: Studio / GameMaker Studio 2 · By YellowAfterlife

"begin" and "end" keywords cause issues with enums

A topic by Dragonite created Nov 27, 2019 Views: 164 Replies: 2
Viewing posts 1 to 3

This is largely the result of me doing stupid things with GML, but you probably would rather have this on record anyway, so: using the begin and end keywords in enums used in Live-enabled scripts causes Live to encounter problems. Strangely, as far as I can tell this only happens with enums, and using the begin and end keywords elsewhere - in control statements, or other code blocks, or whatever - seems to be fine.

There are other reasons I should probably just use curly braces in my code like most of the rest of the programming world (I was mainly doing it because it looks funny) and I'll be going back and changing it now that I've figured out what the problem is, but there there you have it.

To make things even more interesting, I've actually seen at least two different errors from this. In my main project I get

FATAL ERROR in
action number 1
of Async Event: HTTP
for object World: Push :: Execution Error - Variable Index [0,44] out of range [1,44] - -7.l_arr(100001,44)
 at gml_Script_gml_std_haxe_boot_wget (line 3) -        return l_arr[l_index];
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_gml_std_haxe_boot_wget (line 3)
called from - gml_Script_gml_builder_build_line (line 91) -                                                                var l__g13=gml_std_haxe_boot_wget(this[0],this[2]);
called from - gml_Script_gml_builder_build_outer (line 21) -                             if(gml_builder_build_line(this))return true;
called from - gml_Script_gml_builder_build_loop (line 3) -        if(gml_builder_build_outer(this,l_first))return true;
called from - gml_Script_gml_builder_create (line 15) -               gml_builder_build_loop(this,l_src[2]);
called from - gml_Script_gml_program_create (line 24) -               var l_b=gml_builder_create(l_src);
called from - gml_Script_live_update_script_impl (line 60) -        var l_pg=gml_program_create(l_srcs);
called from - gml_Script_live_async_http_1 (line 12) -               script_execute(g_live_update_script,l_name,l_ident,l_code);
called from - gml_Script_live_async_http (line 12) -        live_async_http_1(l_map);
called from - gml_Object_World_Other_62 (line 1) - live_async_http();

which is caused by this enum

enum PauseStages begin
    HIDDEN,
    MAIN,
    PARTY_MENU,     ETC, end

being used in this way in the script with live_call at the top

pause_game(PauseStages.PARTY_MENU);

while when I do the same thing in an isolated environment in the GM Live demo project I get this in the console instead. The program keeps running, but the live call doesn't otherwise udpate:

[live][5:51:48 PM] Runtime error: live_test[L3,c16] `100000` (obj_gmlive) does not have a variable `PauseStages`

Naturally, this isn't an emergency or anything, but it's probably better to know about it than not.

Developer

It only happens with enums because the server uses regular expressions to quickly peek through the entirety of project source code. Redefining keywords through macros will similarly fool it. I cannot promise changing this too soon, as speed is relatively important in that context.

Interesting, and no big deal. Out of curiosity, how come it would give different errors in different situations?