Lua Code:
function zo_callLater(func, ms)
assert(type(func) == "function")
It's so easy to mistype a function name, and all you get is a "function expected instead of nil" X seconds LATER with useless stack trace.
Technically table or userdata may also be called, but there are good reasons not to allow them in zo_callLater:
- checking for the presence of the __call metamethod at the time of zo_callLater is pointless, because it can appear/disappear before LATER
- if there's no __call metamethod LATER, you'll get something like "object cannot be called" error with useless stack trace, and you're left with no hint as to where the error comes from
---
While you're at it, please also change the deferred function to
Lua Code:
function()
EVENT_MANAGER:UnregisterForUpdate(name)
func(id)
end)
i.e. unregister BEFORE you call func. It has already been requested some time ago. Currently it's the other way round, and if func throws an error, it isn't unregistered and keeps being called and spitting errors indefinitely.