Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

GMLive.gml

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

[Answered] Named instances issues

A topic by gnysek created Sep 09, 2020 Views: 221 Replies: 5
Viewing posts 1 to 2

I’m not sure that it’s possible at all, but I’m often using “named instances” in room editor (giving them custom name instead of inst_XXXXXX with random 8-digit HEX).

However when using them with GMLive, I’m getting:

Runtime error: [error] instance#100083(obj_xxx) (obj_xxx) does not have a variable inst_my_custom_name

Is it possible to add this feature ?

Developer
Is it possible to add this feature ?

That's a good question!

Named instances are treated as macros (handled compile-time), meaning that "live" code doesn't know what the values are.

Assuming that GM assigns these in a predictable way (starting from the first room and going layer by layer from top/bottom?), I can probably replicate the algorithm, though there would definitely be caveats if you modify your rooms between starting the game and connecting gmlive-server to it.

I was thinking about some GMLive helper like:

live_link_instance(“my_instance_identifier”, my_instance_identifier); - then after compilation you should have dictionary of names and instances in-game ? User would need to manually enter every instance he wants to read this way.

Developer (1 edit)

For purposes of that workaround, you could use

gml_const_add("inst_name", inst_name);

Perhaps I should expose/document the few of these as part of live_ functions

Yeah, this solves my problem!

Definitely worth mentioning in help docs then.

Developer

I have added more normally-named functions (live_constant_add, live_function_add, live_variable_add) and documentation for them in 1.0.33+