[0.16.51] Integer overflow(?) in script.get_event_handler
Posted: Thu Jul 26, 2018 4:56 pm
What?
So i was fiddling with script.get_event_handler(name) as a method to verify that the name of an event i get is actually a valid event.
And while trying i got some unexpected return values:
script.get_event_handler('invalid-custom-input-name') → Error: Unknown custom-input name, as expected.
script.get_event_handler(2e18) → Nil, this is unexpected as the event doesn't exist. So i expected an error.
script.get_event_handler(2e19) → A function. Not sure what function. But it's returned for any large positive or negative number.
I don't know of any other method to verify if an arbitrary integer or string is a valid first parameter to script.on_event(#1,#2).
(Additionally for custom-input there also seems to be no way to know the event.name (i.e. the integer id).)
Why?
Because i'm trying to write a (somewhat) generic wrapper around script.on_event to make complex scripting more comfortable.
So i was fiddling with script.get_event_handler(name) as a method to verify that the name of an event i get is actually a valid event.
And while trying i got some unexpected return values:
script.get_event_handler('invalid-custom-input-name') → Error: Unknown custom-input name, as expected.
script.get_event_handler(2e18) → Nil, this is unexpected as the event doesn't exist. So i expected an error.
script.get_event_handler(2e19) → A function. Not sure what function. But it's returned for any large positive or negative number.
I don't know of any other method to verify if an arbitrary integer or string is a valid first parameter to script.on_event(#1,#2).
(Additionally for custom-input there also seems to be no way to know the event.name (i.e. the integer id).)
Why?
Because i'm trying to write a (somewhat) generic wrapper around script.on_event to make complex scripting more comfortable.