Skip to content

[LUA] Can you unsubscribe from register_frame, register_start etc? #158

Answered by cuavas
Jakobud asked this question in Q&A
Discussion options

You must be logged in to vote

register_start, register_frame, etc. are deprecated and will be removed at some point. You should use add_machine_reset_notifier, add_machine_frame_notifier, etc. (see the Emulator Interface documentation). These functions return notifier subscriptions which allow unsubscribing.

You can’t manage subscriptions created with the register_X functions. The closest you can do is to subscribe using an anonymous trampoline function that calls the real function by name, and then reassign the name with a function that does nothing (or does something else) when you no longer need it.

For example:

function on_frame()
    -- do something here
end

emu.register_frame(function () on_frame() end)

-- rep…

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@Jakobud
Comment options

@cuavas
Comment options

@Jakobud
Comment options

@cuavas
Comment options

@Jakobud
Comment options

Answer selected by Jakobud
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants