diff options
author | David Athay <ko2fan@gmail.com> | 2008-10-22 13:30:46 +0000 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2008-10-22 13:30:46 +0000 |
commit | dbc83dae37dff1338e1ee6358a0a8d10103278b0 (patch) | |
tree | 4ec1afd5c64c12dff53d9a5ad6b73e7d8689e0af /src/scripting/lua.cpp | |
parent | f598952da95395759d6725bfa5778a66695f1d73 (diff) | |
download | manaserv-dbc83dae37dff1338e1ee6358a0a8d10103278b0.tar.gz manaserv-dbc83dae37dff1338e1ee6358a0a8d10103278b0.tar.bz2 manaserv-dbc83dae37dff1338e1ee6358a0a8d10103278b0.tar.xz manaserv-dbc83dae37dff1338e1ee6358a0a8d10103278b0.zip |
Added enabling and disabling NPCs.
Diffstat (limited to 'src/scripting/lua.cpp')
-rw-r--r-- | src/scripting/lua.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 09ac134e..846a43a1 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -217,6 +217,37 @@ static int LuaNpc_Create(lua_State *s) } /** + * Enable a NPC if it has previously disabled + */ +static int LuaNPC_Enable(lua_State *s) +{ + NPC *p = getNPC(s, 1); + if (p) + { + p->enable(true); + bool b = GameState::insert(p); + assert(b); (void)b; + } + + return 0; +} + +/** + * Disable a NPC + */ +static int LuaNPC_Disable(lua_State *s) +{ + NPC *p = getNPC(s, 1); + if (p) + { + p->enable(false); + GameState::remove(p); + } + + return 0; +} + +/** * Callback for warping a player to another place. * tmw.chr_warp(character, nil/int map, int x, int y) */ @@ -468,7 +499,6 @@ static int LuaBeing_Damage(lua_State *s) return 0; } - /** * Function for getting the x-coordinate of the position of a being */ @@ -781,6 +811,8 @@ LuaScript::LuaScript(): { "npc_message", &LuaNpc_Message }, { "npc_choice", &LuaNpc_Choice }, { "npc_trade", &LuaNpc_Trade }, + { "npc_enable", &LuaNPC_Enable }, + { "npc_disable", &LuaNPC_Disable }, { "chr_warp", &LuaChr_Warp }, { "chr_inv_change", &LuaChr_InvChange }, { "chr_inv_count", &LuaChr_InvCount }, |