Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

GMLive.gml

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

[Fixed in 1.0.26+] Macros & enums glitching workaround

A topic by Bulletproof Outlaws created Nov 22, 2019 Views: 293 Replies: 3
Viewing posts 1 to 3
(2 edits) (+1)

Macros within macros (even basic ones that don't violate the limitations section in the documentation) and macros that use enums are hopefully being fixed as covered here: https://itch.io/post/1003402 (no pressure Vadim I know this stuff is a pain lol)


But in the meantime I just wanted to share the workaround I'm using for anyone else who's having troubles using GMLive till it's fixed:

1) If you're getting the "Runtime error: macro:KEY_LEFT[L1,c17] `100002` (obj_player) does not have a variable `KEYS`" type errors when you call a macro, just copy the macros used by that particular Event/Script, from wherever you define your macros, and paste them at the top of the Event/Script so you have the same macros defined in two places

2) You won't be able to compile with macros defined in two places, so comment out the macros where you just pasted them and compile

3) Once your game is running and GMLive has loaded, un-comment the pasted duplicate macro definitions at the top of that Event/Script

4) Rejoice and celebrate as you watch your code now work!  You shouldn't need to copy the enum definitions, just the macros, but you'll have to copy whatever macros each macro uses so like:

if (live_call()) {return live_result;}
#macro GAME_CENTER    GAME_X + (GAME_WIDTH / 2)
show_message(GAME_CENTER);//<-- this'll give an error

This would need GAME_X and GAME_WIDTH's macros too like:

if (live_call()) {return live_result;}
#macro GAME_X         0
#macro GAME_WIDTH     1920
#macro GAME_CENTER    GAME_X + (GAME_WIDTH / 2)
show_message(GAME_CENTER);//<-- now this will work

I like to throw the whole thing in a region I can collapse for cleanliness while I work, like the top of my Event will be:

#region gmlive
if (live_call()) {return live_result;}
//#macro GAME_X         0
//#macro GAME_WIDTH     1920
//#macro GAME_CENTER    GAME_X + (GAME_WIDTH / 2)
//#macro KEY_LEFT       KEYS[keys.left]
#endregion
show_message(GAME_CENTER);//<-- this'll give errors when you first run it but
                          //then you un-comment the macro lines and it'll work

Or for Scripts:

#region gmlive
if (argument_count) {
    var argument_arr = array_create(argument_count);
    for (var i = 0; i < argument_count; i++) {argument_arr[i] = argument[i];}
    if (live_call_ext(argument_arr)) return live_result;
} else {
    if (live_call()) {return live_result;}
}
//#macro GAME_X         0
//#macro GAME_WIDTH     1920
//#macro GAME_CENTER    GAME_X + (GAME_WIDTH / 2)
//#macro KEY_LEFT       KEYS[keys.left]
#endregion
show_message(GAME_CENTER);//<-- this'll give errors when you first run it but
                          //then you un-comment the macro lines and it'll work

It's a bit of a pain because if your game crashes or you have to run it again because you've added new events or objects etc, you'll have to comment the duplicate macro definitions out, compile, then un-comment them...but if you're sitting down for a long session of fiddling with UI button layouts or animation tweaks or whatever where you don't have to re-compile this is a pretty fast way to deal with the errors

Hope this helps anyone running into this!

Just saw the latest update went up!  Have you had a chance to look into this "macro within a macro" bug yet?  https://itch.io/post/1003402  Thanks :)

Developer

Not yet - I intend to handle this by reworking macros completely (to match the way GM works), but I've been slightly occupied by other work.

Cool no worries! Just wasn't sure if it got lost in the shuffle with the new shader features etc :)