I got memed by globals but it's finally done. I was inspired by d3134682 to fully remove all the copypasted code in lua_hooklib.c. Now hooks are very easy to set up.
I also fixed a bug where some hooks were not called at all.  Hooks may be faster too I dunno. This requires a lot of testing of course.
Hooks are faster. I added 100 mobj thinkers and went to CEZ2. The improvement in game logic time was around 245 ms to 52 ms.
There is some bit array code that should be removed once !1292 (merged) is merged.
HUD hooks not included, but I may want to tackle that too...
Merge !1319 (merged) first.