Ported the engine to lua5.2.

+ Missed a few LUA_GLOBALSINDEX calls.
+ Made tablespaced files work again in lua 5.2
+ Made the editor work against lua 5.2
Support nil parameter when using adopt policy

Test if pointer is null and only release if that is the case.
This way nil can be passed from Lua to C++ as null when using the adopt policy
without crashing the application (by trying to access a member of a null pointer).