Don't know if it's better but here's a way that seem
to combine the pro's of the 2 above 2 ways.
-- start of Lua example
t_events = {
KeyPressed = OnKeyPressed,
LeftClick = OnLeftClick,
DoubleClick = function (x,y) print (x,y) end,
-- etc.
}
function OnEvent (event, ...)
local f = t_events [event]
if f then return f (...) end
end
SetEvent (OnEvent)
-- end of Lua example
C provides SetEvent function, and Lua registers only
*one* event handler. C calls that handler passing
event name (a string) and any number of parameters.