Code: Select all
script.on_event('test-custom-input', function(event) end, nil) -- raises error
Code: Select all
script.on_event('test-custom-input', function(event) end) -- doesn't raise error
Code: Select all
script.on_event('test-custom-input', function(event) end, nil) -- raises error
Code: Select all
script.on_event('test-custom-input', function(event) end) -- doesn't raise error
Code: Select all
function register_event_handler(event, handler, event_filters)
if event_filters then
script.on_event(event, handler, event_filters)
else
script.on_event(event, handler)
end
end
This would not work in case I want to set the filter to nil for events that do support filters.curiosity wrote: Mon Feb 20, 2023 11:04 am edit: for the described use it is easily circumvented as such:
...
Sorry, you are right. I somehow thought omitting the nil would keep the previously set filter.curiosity wrote: Mon Feb 20, 2023 11:36 am Actually, in this specific case it will work, because the nil is not meaningful. Passing nil for filters is the same as passing nothing.