diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2008-10-27 16:53:13 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2008-10-27 16:53:13 +0000 |
commit | fb2b268a2616617800b92330e09278042e50e7d7 (patch) | |
tree | 326f730314249c159adce0971d26e51a26acb358 /src | |
parent | bbb9a98aeefaa1609dbd2455c102750c5005e05f (diff) | |
download | manaserv-fb2b268a2616617800b92330e09278042e50e7d7.tar.gz manaserv-fb2b268a2616617800b92330e09278042e50e7d7.tar.bz2 manaserv-fb2b268a2616617800b92330e09278042e50e7d7.tar.xz manaserv-fb2b268a2616617800b92330e09278042e50e7d7.zip |
Script binding for spawning effets from scripts.
Diffstat (limited to 'src')
-rw-r--r-- | src/scripting/lua.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 7f421c67..c0c7a95c 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -33,6 +33,7 @@ extern "C" { #include "game-server/buysell.hpp" #include "game-server/character.hpp" #include "game-server/collisiondetection.hpp" +#include "game-server/effect.hpp" #include "game-server/gamehandler.hpp" #include "game-server/inventory.hpp" #include "game-server/item.hpp" @@ -874,6 +875,34 @@ static int LuaNoteOnDeath(lua_State *s) return 0; } +/** + * Triggers a special effect from the clients effects.xml + * tmw.effect_create (id, x, y) + */ +static int LuaEffect_Create(lua_State *s) +{ + if (!lua_isnumber(s, 1) || + !lua_isnumber(s, 2) || + !lua_isnumber(s, 3)) + { + raiseScriptError(s, "effect_create called with incorrect parameters."); + return 0; + } + lua_pushlightuserdata(s, (void *)®istryKey); + lua_gettable(s, LUA_REGISTRYINDEX); + Script *t = static_cast<Script *>(lua_touserdata(s, -1)); + + MapComposite *m = t->getMap(); + int id = lua_tointeger(s, 1); + int x = lua_tointeger(s, 2); + int y = lua_tointeger(s, 3); + + Effects::show(id, m, Point(x, y)); + + return 0; +} + + LuaScript::LuaScript(): nbArgs(-1) { @@ -906,6 +935,7 @@ LuaScript::LuaScript(): { "chatmessage", &LuaChatmessage }, { "get_beings_in_circle", &LuaGetBeingsInCircle }, { "note_on_death", &LuaNoteOnDeath }, + { "effect_create", &LuaEffect_Create }, { NULL, NULL } }; luaL_register(mState, "tmw", callbacks); |