Patch to compile with Lua 5.2

Mostly switching usage of lua_reg to luaL_Reg where used.
Updated CMake rules to check for Lua52