Lua cleanup

Move old functions to compat.lua
Remove unused m_realPos in script environment