Skip to main content

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

Registered functions don't use the correct "self"

A topic by CannotThink created 41 days ago Views: 73 Replies: 3
Viewing posts 1 to 3

I'm using live_function_add to replace the built-in instance_destroy with a modified version of itself, but it doesn't work because "self" becomes some internal GMLive struct

When I make the replacement function log self to the debug output it shows "call_func0([ 0,6,18,undefined,97 ], function gml_Script_anon@107@scr_gmlive_instance@scr_gmlive_instance)

Developer

This isn’t mentioned in the live documentation, but signature argument can have prefixes indicating self/other use, like this

live_function_add(":instance_destroy(?id, ?perform)", my_func);
live_function_add("::event_perform(?type, ?numb)", my_func);

Thanks so much. Personally it should probably use those by default, unless it's slower?

Developer

It’s because instead of

return func(...);

it has to do something like

with (ctx._other) {
    with (ctx._self) {
        return func(...);
    }
}

And there are a couple edge cases where doing with (<id of a freshly destroyed instance>) will not do anything, so you don’t always want your with chain.