summaryrefslogtreecommitdiff
path: root/src/scripting/lua.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/scripting/lua.cpp')
-rw-r--r--src/scripting/lua.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index aead80cb..e711623d 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -1151,6 +1151,18 @@ static int LuaTest_Tableget(lua_State *s)
return 4;
}
+/**
+ * Returns the ID of the current map
+ */
+static int LuaGet_MapId(lua_State *s)
+{
+ lua_pushlightuserdata(s, (void *)&registryKey);
+ lua_gettable(s, LUA_REGISTRYINDEX);
+ Script *t = static_cast<Script *>(lua_touserdata(s, -1));
+ int id = t->getMap()->getID();
+ lua_pushinteger(s, id);
+ return 1;
+}
LuaScript::LuaScript():
nbArgs(-1)
@@ -1191,6 +1203,7 @@ LuaScript::LuaScript():
{ "note_on_death", &LuaNoteOnDeath },
{ "effect_create", &LuaEffect_Create },
{ "test_tableget", &LuaTest_Tableget },
+ { "get_map_id", &LuaGet_MapId },
{ NULL, NULL }
};
luaL_register(mState, "tmw", callbacks);