From 05de4c0aa765fb1a448687c068ddae9ecd880542 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Thu, 7 Feb 2008 01:18:39 +0000 Subject: Implemented LUA callback function for creating monsters. --- src/scripting/lua.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 048bc6f0..d0490547 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -36,6 +36,8 @@ extern "C" { #include "game-server/item.hpp" #include "game-server/itemmanager.hpp" #include "game-server/mapmanager.hpp" +#include "game-server/monster.hpp" +#include "game-server/monstermanager.hpp" #include "game-server/npc.hpp" #include "game-server/quest.hpp" #include "game-server/state.hpp" @@ -367,6 +369,39 @@ static int LuaNpc_Trade(lua_State *s) return 0; } +/** + * Callback for creating a monster on the current map. + * tmw.monster_create(int type, int x, int y) + */ +static int LuaMonster_Create(lua_State *s) +{ + if (!lua_isnumber(s, 1) || !lua_isnumber(s, 2) || !lua_isnumber(s, 3)) + { + LOG_WARN("LuaMonster_Create called with incorrect parameters."); + return 0; + } + lua_pushlightuserdata(s, (void *)®istryKey); + lua_gettable(s, LUA_REGISTRYINDEX); + Script *t = static_cast