summaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/CMakeLists.txt1
-rw-r--r--src/script/lua_api/l_client.cpp33
-rw-r--r--src/script/lua_api/l_client.h36
-rw-r--r--src/script/lua_api/l_env.cpp6
-rw-r--r--src/script/lua_api/l_env.h2
-rw-r--r--src/script/lua_api/l_object.cpp2
6 files changed, 75 insertions, 5 deletions
diff --git a/src/script/lua_api/CMakeLists.txt b/src/script/lua_api/CMakeLists.txt
index e82560696..ea3d75ffa 100644
--- a/src/script/lua_api/CMakeLists.txt
+++ b/src/script/lua_api/CMakeLists.txt
@@ -23,5 +23,6 @@ set(common_SCRIPT_LUA_API_SRCS
PARENT_SCOPE)
set(client_SCRIPT_LUA_API_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/l_client.cpp
${CMAKE_CURRENT_SOURCE_DIR}/l_mainmenu.cpp
PARENT_SCOPE)
diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp
new file mode 100644
index 000000000..9c478602a
--- /dev/null
+++ b/src/script/lua_api/l_client.cpp
@@ -0,0 +1,33 @@
+/*
+Minetest
+Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
+Copyright (C) 2017 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include "l_client.h"
+#include "l_internal.h"
+
+int ModApiClient::l_get_current_modname(lua_State *L)
+{
+ lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_CURRENT_MOD_NAME);
+ return 1;
+}
+
+void ModApiClient::Initialize(lua_State *L, int top)
+{
+ API_FCT(get_current_modname);
+}
diff --git a/src/script/lua_api/l_client.h b/src/script/lua_api/l_client.h
new file mode 100644
index 000000000..332f00132
--- /dev/null
+++ b/src/script/lua_api/l_client.h
@@ -0,0 +1,36 @@
+/*
+Minetest
+Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
+Copyright (C) 2017 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef L_CLIENT_H_
+#define L_CLIENT_H_
+
+#include "lua_api/l_base.h"
+
+class ModApiClient : public ModApiBase
+{
+private:
+ // get_current_modname()
+ static int l_get_current_modname(lua_State *L);
+
+public:
+ static void Initialize(lua_State *L, int top);
+};
+
+#endif
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp
index 2722e35a4..442c4b99a 100644
--- a/src/script/lua_api/l_env.cpp
+++ b/src/script/lua_api/l_env.cpp
@@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "lua_api/l_vmanip.h"
#include "common/c_converter.h"
#include "common/c_content.h"
-#include "scripting_game.h"
+#include "serverscripting.h"
#include "environment.h"
#include "server.h"
#include "nodedef.h"
@@ -49,7 +49,7 @@ struct EnumString ModApiEnvMod::es_ClearObjectsMode[] =
void LuaABM::trigger(ServerEnvironment *env, v3s16 p, MapNode n,
u32 active_object_count, u32 active_object_count_wider)
{
- GameScripting *scriptIface = env->getScriptIface();
+ ServerScripting *scriptIface = env->getScriptIface();
scriptIface->realityCheck();
lua_State *L = scriptIface->getStack();
@@ -92,7 +92,7 @@ void LuaABM::trigger(ServerEnvironment *env, v3s16 p, MapNode n,
void LuaLBM::trigger(ServerEnvironment *env, v3s16 p, MapNode n)
{
- GameScripting *scriptIface = env->getScriptIface();
+ ServerScripting *scriptIface = env->getScriptIface();
scriptIface->realityCheck();
lua_State *L = scriptIface->getStack();
diff --git a/src/script/lua_api/l_env.h b/src/script/lua_api/l_env.h
index 21b235f84..322959411 100644
--- a/src/script/lua_api/l_env.h
+++ b/src/script/lua_api/l_env.h
@@ -242,7 +242,7 @@ public:
};
struct ScriptCallbackState {
- GameScripting *script;
+ ServerScripting *script;
int callback_ref;
int args_ref;
unsigned int refcount;
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index 9352812ab..be454ad45 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_sao.h"
#include "server.h"
#include "hud.h"
-#include "scripting_game.h"
+#include "serverscripting.h"
struct EnumString es_HudElementType[] =
{