Page 1 of 1

[2.0.77] Silent discard of script.raise_event

Posted: Fri May 22, 2026 9:16 pm
by hgschmie
The docs for LuaBootstrap::raise_event clearly state for the data: "Table with extra data that will be passed to the event handler. Any invalid LuaObjects will silently stop the event from being raised."

This is understandable but I wish we could get some sort of feedback. Would it be possible for raise_event to return a boolean indicating success or failure? Given that currently it returns nothing (nil), maybe return "true" if the call failed and false if it succeeded (that would make it possible to write if script_raise_event(...) then ... error managing code ... end for any version.

I have a few events that I raise that have big payloads. The can (in somewhat rare cases) relate to invalid objects. Currently I have the choice of my events not firing in that case or always doing expensive payload sanitation which I almost never need. With a return code, I could replace this:

Code: Select all

    local data = generate_playload()
    sanitize_payload_in_an expensive_way(data)
    script.raise_event(my_event, data)
with

Code: Select all

    local data = generate_playload()
    if script.raise_event(my_event, data) then
        sanitize_payload_in_an expensive_way(data)
        assert (not script.raise_event(my_event, data))
    end
Any chance we could something like that? Maybe for 2.1?

Re: [2.0.77] Silent discard of script.raise_event

Posted: Tue Jun 09, 2026 12:26 am
by The_LORD_thy_GOD
I agree that this behavior is bad and should be addressed in some way. Personally I think it should just allow invalid objects to pass with the understanding that mods receiving mod-generated custom events must validate payloads.

That being said, there is a workaround possible in current API: I have my custom events that need a large payload just send an integer ID, which the receiving mod can then use to retrieve the payload via a remote interface -- this side-steps the problem.