--- xmoto-0.5.11/configure.in.old	2014-03-29 10:35:24.000000000 +0000
+++ xmoto-0.5.11/configure.in	2018-09-29 03:51:05.210000000 +0000
@@ -174,6 +174,7 @@
 AC_CHECK_HEADER(lua50/lua.h,  AC_DEFINE(HAVE_LUA50_LUA_H) [USE_LUA_VERSION="5.0"])
 AC_CHECK_HEADER(lua51/lua.h,  AC_DEFINE(HAVE_LUA51_LUA_H) [USE_LUA_VERSION="5.1"])
 AC_CHECK_HEADER(lua5.1/lua.h, AC_DEFINE(HAVE_LUA5_1_LUA_H)[USE_LUA_VERSION="5.1"])
+AC_CHECK_HEADER(lua5.3/lua.h, AC_DEFINE(HAVE_LUA5_3_LUA_H)[USE_LUA_VERSION="5.3"])
 AC_DEFINE(LUA_COMPAT_MODULE, 1)
 
 AC_LANG_PUSH([C++])
--- xmoto-0.5.11/src/include/xm_lua.h.old	2011-10-11 20:18:17.000000000 +0000
+++ xmoto-0.5.11/src/include/xm_lua.h	2018-09-29 03:51:49.230000000 +0000
@@ -4,7 +4,11 @@
     #include "lauxlib.h"
     #include "lualib.h"
   #else
-    #if defined(HAVE_LUA5_1_LUA_H)
+    #if defined(HAVE_LUA5_3_LUA_H)
+      #include <lua5.3/lua.h>
+      #include <lua5.3/lauxlib.h>
+      #include <lua5.3/lualib.h>
+    #elif defined(HAVE_LUA5_1_LUA_H)
       #include <lua5.1/lua.h>
       #include <lua5.1/lauxlib.h>
       #include <lua5.1/lualib.h>
--- xmoto-0.5.11/src/LuaLibBase.cpp.old	2014-03-29 09:46:24.000000000 +0000
+++ xmoto-0.5.11/src/LuaLibBase.cpp	2018-09-30 23:34:51.800000000 +0000
@@ -42,7 +42,13 @@
   luaL_requiref(m_pL, LUA_TABLIBNAME,  luaopen_table, 1);
 #endif
 
+#if LUA_VERSION_NUM < 503
   luaL_openlib(m_pL, i_libname.c_str(), i_reg, 0);
+#else
+  lua_newtable(m_pL);
+  luaL_setfuncs(m_pL, i_reg, 0);
+  lua_setglobal(m_pL, i_libname.c_str());
+#endif
 }
 
 LuaLibBase::~LuaLibBase() {