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)
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
