Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Error on certain functions.

A topic by Neverdusk created Jun 04, 2021 Views: 367 Replies: 9
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.

Sorry for necroing a long dead post, but I'm having a similar error and I've looked at the documentation you've linked. When I try to have GMLive reload an object's Draw GUI event, i get

[GMLive][7/14/2026 3:11:58 PM][ERROR] Runtime error: [error] Script index must be a number, got `undefined` (undefined)


The error in question stems from this nested function:

function GUIMask() {     
live_auto_call     
static surf = undefined;          
static Mask = function() {         
    live_name = "GUIMask:Mask"         
        if (live_call()) return live_result;         
        if (not surface_exists(surf)) {             
            surf = surface_create(display_get_gui_width(), display_get_gui_height());         
    }                 
    surface_set_target(surf);         
    draw_clear_alpha(c_black, 0);         
    gpu_set_colorwriteenable(false, false, false, true);     
};     
static Content = function() {         
    live_name = "GUIMask:Content"         
        if (live_call()) return live_result;         
        gpu_set_colorwriteenable(true, true, true, false);     
};     
static Render = function() {         
    live_name = "GUIMask:Render"         
    if (live_call()) return live_result;         
    gpu_set_colorwriteenable(true, true, true, true);         
    surface_reset_target();         
    draw_surface(surf, 0, 0);     
    }; 
} 
GUIMask();

Any help would be appreciated. I'm using Game Maker LTS 2026.0.0.16 with Runtime v2026.0.0.23.

Developer

Hard to tell from that alone, but try removing the outer-most live_auto_call - we don’t have true closures so GMLive can’t re-create some of the behavior with static / Script.staticFunc().

That didn't seem to work. I have a "live_auto_call" at the beginning of the event that calls this function, but I'll admit I don't fully understand the nitty gritty of how GMLive works. Will it just not work with static functions? Or could this have something to do with calling a nested function? The code I'm trying to test is in the Draw GUI event, so the code I've shared isn't even directly relevant and shouldn't need to change at runtime, which is why I'm confused that it stops working only after reloading with GMLive.

Developer

IIRC the specific case that’s weird is

function scr_some() {
    live_auto_call;
    static counter = 0;
    static a = function() { counter += 1 }
}

and then doing scr_some.a()

If you can reproduce this in a blank project, please email me a copy and I’ll have a peek

If you don’t want to do anything, I guess you can move the code to a different (non-static) script, but I can’t tell you from the information so far whether that’s actually what’s happening.

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.