Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

GMLive.gml

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

Attempt to dispatch event on non-instance object error when using event_inherited()

A topic by _MHG_ created 56 days ago Views: 184 Replies: 9
Viewing posts 1 to 3
(1 edit)

Hi,

Reporting that GMLive produces the following error in the output window without updating saved changes in the code:

[ERROR] Runtime error: [error] Attempt to dispatch event on non-instance object called from [obj_name]

I've update GMLive to the latest version and tested this with both the gmlive-server.exe and gmlive-server-alt.exe files. Of course, using GMLive with event_inherited used to work without issues before the update to GM. Live updating seems to work fine when event_inherited is commented out.

Hope this can be fixed. 

Thanks! 

Developer

If calling a script that calls event_inherited() doesn’t work either, that a GameMaker bug

Okay, so I tested to check things out and would like to report the following:

In the step event for a child object, I run a function called fnc_eve() that is stored in a script container. This function only contains:

event_inherited();

If I have the parent object of the child run a simple print debug message in its step event, then I can see the debug message printed when an instance of the child is present in the room. No crashes or anything.

When I add the "if (live_call()) return live_result;" along with either the event_inherited() call or fnc_eve(), no crashes or error messages are printed in the output window. When I make a change and save, the change does not happen, and instead the output window shows the message in the op. 

Not sure what to make of it, but doesn't seem like a GameMaker bug?

Thanks.

Developer

Not sure what to make of it, but doesn’t seem like a GameMaker bug?

Don’t believe me? Add the following to your fnc_eve():

show_debug_message([typeof(self), instanceof(self), self]);

In 2023.8, this shows

[ "struct","instance",{ ... variables from the instance } ]

In 2024.2, this shows

[ "struct","Object",{ vm_group_call_on_call_field : function gml_Script_vm_group_call_on_call_field, vm_group_call_on_construct : function gml_Script_vm_group_call_on_construct, ...

So what’s that? The global struct? I wonder if this only got half-fixed

(1 edit)

Not saying I don't believe you, but that's not what I'm seeing (with GMLive disabled).

fnc_eve() has the following:

function fnc_eve()  

event_inherited();

show_debug_message([typeof(self), instanceof(self), self]);

}


The child object has fnc_eve() running it its step event. The output window shows the following:

[ "struct","instance",{ ammo_rld_manual_rt : 12, pnce_dur_default : 200, pnce_upkeep_default : 100, pnce_img_spd_ini : 0.25, pnce_ini_vsp : 6, pnce_ini_wsp : 8, pnce_end_wsp : 8, pnce_end_vsp : 4, pnce_enemy_rec : 75, proj_max : 0, use_type : "use_en", addon_snd_sys : "alarm", proj_curr : 0, ammo_rld_amt_default : 1, proj_snd_tri_hv : ref sound 358, proj_fired : 0, brth_phase : 0, brth_duration_def_fr_multi : 130, brth_dur_def_lt : 120, brth_type : 0, cancel_force_dur : 150, alarm_snd_max : 0, fire : 0, can_snd : 1, alarm_snd : 0, ammo_fr_rld_very_slow : 420, can_snd_loop : 1, cancel_allow : 0, proj_dir_l_b : 180, proj_dir_r_b : 0, cancel_force : 0, proj_grav_b : 0, proj_speed_b : 0, proj_dmg_b : 0, proj_img_speed_b : 0, proj_img_index_b : 0, proj_y_offset_b : 0, proj_x_offset_b : 0, can_shoot : 1, proj_inst_b : ref object 484, overlay_sprite_jump : ref sprite 1329, can_fire_hov_rt_default : 75, overlay_sprite_stand : ref sprite 1329, alarm_can_shoot_curr_b : 0, cancel_allow_dur_quick : 30, dir_hov_type : "n"

,...., pnce_upkeep_curr : 100 } ]

I'm not seeing the vm_group_call_on ... stuff. Are you using the same GM runtime as I am (2024.2.0.163)?

Developer (1 edit)

I cited what happens in a live-reloaded script after it has been modified once (thus is being compiled-executed by GMLive) - something across the built-in functions now works differently from the last update, and there are no warnings about this in the release notes.

If the same code has different outputs depending on GameMaker runtime version used, that is not intended behaviour.

Thanks for the reply, but I don't know what to do with this response. GMLive is clearly not working correctly with event inheritance. If I report a bug to YYG and tell them this is an issue with this extension, you know they'll just tell me they won't look into how GM works with non YYG extensions.

So is event_inherited just not going to work with GMLive moving forward or what? I'd be happy to file a bug report, but whatever it is that is causing event_inherited to no longer work with GMLive has to be replicated without any interaction with GMLive. If you know how to replicate it and tell me, I can file the bug report.

Developer(+1)

It’s not just event_inherited - all functions/scripts are now being called with an incorrect self value.

In time, I will figure out what is it that’s broken this time around (GMLive’s a big extension, that’s not fast) and file a bug report, or someone else might.

Either way, I recommend sticking to 2023.8 or 2023.11 runtimes until 2024.2 gets fixed up a bit.

Developer (1 edit)

The underlying issue is as following:

globalvar funcs;
function scr_test() {
	funcs = [scr_test_1];
	var f = funcs[0]; f();
	funcs[0]();
	global.funcs[0]();
}
function scr_test_1() {
	show_debug_message(self);
}

On 2023.11, all three calls will print the contents of the current instance.

On 2024.2, call #2 will print the contents of global instead.

I guess that’s a bug..?

This isn’t too hard to workaround, but I’ll need to figure out all places where I’m calling something from an array.

(+1)

Thanks for this. I will make a report on this to YYG shortly if you haven't already.