Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

GMLive.gml

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

[Solved] Error on certain functions.

A topic by Neverdusk created Jun 04, 2021 Views: 158 Replies: 5
Viewing posts 1 to 6
(1 edit)

I sometimes get this error https://pastebin.com/XrZVEQuM when putting "if (live_call()) return live_result;" in certain scripts. I have no idea why it happens, since the scripts run completely normally until I add that line to them. Then they don't run at all and just return undefined.

In this example, info_set_value is the only script using GMLive. None of the functions that call it have any GMLive functions in them. The moment I remove GMLive, everything works perfectly. It seems to trigger this error for no reason. 

I've also tried replacing info_set_value with other scripts, and they all work fine until I add GMLive to them. GMLive throws up an error and the script returns undefined instead of running. 

Everything is otherwise set up normally. Live script reloading works, and I can use it in certain scripts, but not others.

It's worth noting that the the script (info_set_value) seems to work except when it's nested inside a lot of scripts. The script works in several object Create events, but it doesn't work inside a nest of per-Step functions.  

Actually, I placed it directly in the Step event and the same issue either. So the nest doesn't have anything to do with it. The second 

[live][6/4/2021 6:53:36 PM] Ready!
[live][6/4/2021 6:53:36 PM] Reloaded info_set_value.
[live][6/4/2021 6:53:36 PM] Reloaded oPlayer:Create_0.
[live][6/4/2021 6:53:36 PM] Reloaded oEnemy:Create_0.
[live][6/4/2021 6:53:36 PM] Reloaded obj_gmlive:Draw_0.

appears in the Output window, the script simply fails to work. 

Okay, after a lot of debugging, I seem to have figured out the issue: GMLive doesn't seem to support getting variables from stored instance IDs.

In the script that was breaking, one argument was "_instance", a private variable that would hold an instance's ID. So an object might call this script with info_set_value(instanceID,arg1,arg2). 

Inside the script, there were a number of lines that would grab local variables from the instance whose ID was stored in _instance. So, for example, it would say:
var _name = _instance.name;
var_ color = _instance.color;

However, GMLive didn't seem to realize "_instance" was an instance ID.

When I switched _instance to simply be the object's built-in "id" variable, it suddenly stopped throwing errors. For example:
var _name = id.name;
var _color = id.color;

Again, the script worked perfectly when GMLive was removed, so there were no issues with the actual "_instance" variable until GMLive was added. I even tried replacing "_instance" with an object_index an it also worked:
var _name = oEnemy.name;
var _color = oEnemy.color;

So it seems GMLive just can't handle stored instance IDs - if I'm correct. The way my project is set up, this is something really important to me, because many if not most of my scripts rely on supplying instance IDs to work as private variables for their functions.

Developer (1 edit)

I’m assuming that your script is like

function info_set_value(_instance) {
    if (live_call()) return live_result;
}

and you are not passing the argument into live_call as the documentation suggests.

You're absolutely right. I watched the video tutorial but somehow didn't think to dig deeper into the documentation. I did have another script that used arguments and seemed to work with GMLive perfectly - but that script didn't take any instance IDs as arguments. 

Thank you for taking the time to answer, and sorry for making such a long post for such a silly mistake.