summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_base.cpp
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2013-08-11 04:09:45 +0200
committerKahrl <kahrl@gmx.net>2013-08-14 21:03:33 +0200
commit4e1f50035e860a00636ca5d804c267119df99601 (patch)
treec6cab522305ef2a5b9cfdb3685340d57590f1ff1 /src/script/lua_api/l_base.cpp
parent6228d634fb31d1ce925d1fdc2dac022629a007ef (diff)
downloadminetest-4e1f50035e860a00636ca5d804c267119df99601.tar.gz
minetest-4e1f50035e860a00636ca5d804c267119df99601.tar.bz2
minetest-4e1f50035e860a00636ca5d804c267119df99601.zip
Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenu
Diffstat (limited to 'src/script/lua_api/l_base.cpp')
-rw-r--r--src/script/lua_api/l_base.cpp47
1 files changed, 20 insertions, 27 deletions
diff --git a/src/script/lua_api/l_base.cpp b/src/script/lua_api/l_base.cpp
index b1766e6df..b8d673ee4 100644
--- a/src/script/lua_api/l_base.cpp
+++ b/src/script/lua_api/l_base.cpp
@@ -17,32 +17,35 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "cpp_api/scriptapi.h"
#include "lua_api/l_base.h"
-#include "common/c_internal.h"
-#include "log.h"
-
-extern "C" {
-#include "lua.h"
+#include "lua_api/l_internal.h"
+#include "cpp_api/s_base.h"
+
+ScriptApiBase* ModApiBase::getScriptApiBase(lua_State *L) {
+ // Get server from registry
+ lua_getfield(L, LUA_REGISTRYINDEX, "scriptapi");
+ ScriptApiBase *sapi_ptr = (ScriptApiBase*) lua_touserdata(L, -1);
+ lua_pop(L, 1);
+ return sapi_ptr;
}
-ModApiBase::ModApiBase() {
- ScriptApi::registerModApiModule(this);
+Server* ModApiBase::getServer(lua_State *L) {
+ return getScriptApiBase(L)->getServer();
}
-Server* ModApiBase::getServer(lua_State* L) {
- return get_scriptapi(L)->getServer();
+Environment* ModApiBase::getEnv(lua_State *L) {
+ return getScriptApiBase(L)->getEnv();
}
-Environment* ModApiBase::getEnv(lua_State* L) {
- return get_scriptapi(L)->getEnv();
+GUIEngine* ModApiBase::getGuiEngine(lua_State *L) {
+ return getScriptApiBase(L)->getGuiEngine();
}
-bool ModApiBase::registerFunction( lua_State* L,
- const char* name,
- lua_CFunction fct,
- int top
- ) {
+bool ModApiBase::registerFunction(lua_State *L,
+ const char *name,
+ lua_CFunction fct,
+ int top
+ ) {
//TODO check presence first!
lua_pushstring(L,name);
@@ -51,13 +54,3 @@ bool ModApiBase::registerFunction( lua_State* L,
return true;
}
-
-struct EnumString es_BiomeTerrainType[] =
-{
- {BIOME_TERRAIN_NORMAL, "normal"},
- {BIOME_TERRAIN_LIQUID, "liquid"},
- {BIOME_TERRAIN_NETHER, "nether"},
- {BIOME_TERRAIN_AETHER, "aether"},
- {BIOME_TERRAIN_FLAT, "flat"},
- {0, NULL},
-};