]> git.lizzy.rs Git - minetest.git/blobdiff - src/script/scripting_game.cpp
Fix memory leaks due to messed up memory handling for particles as well as their...
[minetest.git] / src / script / scripting_game.cpp
index dfbf471d23fcfc1bf7e64d5dd00738226d9f3271..e716bc979489bc357617ec2f2d8f4cce73ff95d8 100644 (file)
@@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 */
 
 #include "scripting_game.h"
+#include "server.h"
 #include "log.h"
 #include "cpp_api/s_internal.h"
 #include "lua_api/l_base.h"
@@ -35,6 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "lua_api/l_server.h"
 #include "lua_api/l_util.h"
 #include "lua_api/l_vmanip.h"
+#include "lua_api/l_settings.h"
 
 extern "C" {
 #include "lualib.h"
@@ -49,12 +51,10 @@ GameScripting::GameScripting(Server* server)
 
        //TODO add security
 
-       luaL_openlibs(getStack());
-
        SCRIPTAPI_PRECHECKHEADER
 
-       // Create the main minetest table
-       lua_newtable(L);
+       lua_getglobal(L, "core");
+       int top = lua_gettop(L);
 
        lua_newtable(L);
        lua_setfield(L, -2, "object_refs");
@@ -62,15 +62,15 @@ GameScripting::GameScripting(Server* server)
        lua_newtable(L);
        lua_setfield(L, -2, "luaentities");
 
-       lua_setglobal(L, "minetest");
-
        // Initialize our lua_api modules
-       lua_getglobal(L, "minetest");
-       int top = lua_gettop(L);
        InitializeModApi(L, top);
        lua_pop(L, 1);
 
-       infostream << "SCRIPTAPI: initialized game modules" << std::endl;
+       // Push builtin initialization type
+       lua_pushstring(L, "game");
+       lua_setglobal(L, "INIT");
+
+       infostream << "SCRIPTAPI: Initialized game modules" << std::endl;
 }
 
 void GameScripting::InitializeModApi(lua_State *L, int top)
@@ -96,4 +96,10 @@ void GameScripting::InitializeModApi(lua_State *L, int top)
        NodeMetaRef::Register(L);
        NodeTimerRef::Register(L);
        ObjectRef::Register(L);
+       LuaSettings::Register(L);
+}
+
+void log_deprecated(std::string message)
+{
+       log_deprecated(NULL,message);
 }