From f562abbf2980c66e5c16f30ea667b758e796ae4e Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Fri, 10 Aug 2007 14:45:41 +0000 Subject: Added Lua function for warping people around. --- src/scripting/lua.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 9cac37d0..3ed5ca98 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -32,6 +32,7 @@ extern "C" { #include "resourcemanager.h" #include "game-server/character.hpp" #include "game-server/gamehandler.hpp" +#include "game-server/mapmanager.hpp" #include "game-server/npc.hpp" #include "game-server/state.hpp" #include "net/messageout.hpp" @@ -159,6 +160,42 @@ static int LuaObj_CreateNpc(lua_State *s) return 1; } +/** + * Callback for warping a player to another place. + * (1: Character) (2: nil/int) (3: int) (4: int) + */ +static int LuaChr_Warp(lua_State *s) +{ + Character *q = getCharacter(s, 1); + bool b = lua_isnil(s, 2); + if (!q || !(b || lua_isnumber(s, 2)) || + !lua_isnumber(s, 3) || !lua_isnumber(s, 4)) + { + LOG_WARN("LuaChr_Warp called with incorrect parameters."); + return 0; + } + MapComposite *m; + if (b) + { + lua_pushlightuserdata(s, (void *)®istryKey); + lua_gettable(s, LUA_REGISTRYINDEX); + Script *t = static_cast