diff options
author | Philipp Sehmisch <crush@themanaworld.org> | 2009-09-27 17:14:12 +0200 |
---|---|---|
committer | Philipp Sehmisch <crush@themanaworld.org> | 2009-09-27 17:14:12 +0200 |
commit | 1847d5ac2a5a93fa66d1b98a986ca7072a86037e (patch) | |
tree | c23f2da6ee1f14554a70849e54d961f029377590 /src/scripting/lua.cpp | |
parent | b2bbb73f3fab10b238a61bf3aa185d80e6d2070f (diff) | |
download | manaserv-1847d5ac2a5a93fa66d1b98a986ca7072a86037e.tar.gz manaserv-1847d5ac2a5a93fa66d1b98a986ca7072a86037e.tar.bz2 manaserv-1847d5ac2a5a93fa66d1b98a986ca7072a86037e.tar.xz manaserv-1847d5ac2a5a93fa66d1b98a986ca7072a86037e.zip |
Added script bindings and netcode for creating being-bound effects.
Diffstat (limited to 'src/scripting/lua.cpp')
-rw-r--r-- | src/scripting/lua.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 4b2513e6..38177e98 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -1030,12 +1030,18 @@ static int being_register(lua_State *s) /** * Triggers a special effect from the clients effects.xml * tmw.effect_create (id, x, y) + * tmw.effect_create (id,being) */ static int effect_create(lua_State *s) { if (!lua_isnumber(s, 1) || - !lua_isnumber(s, 2) || - !lua_isnumber(s, 3)) + ( + !lua_isnumber(s, 2) || + !lua_isnumber(s, 3) + ) && ( + !lua_isuserdata(s, 2) + ) + ) { raiseScriptError(s, "effect_create called with incorrect parameters."); return 0; @@ -1046,10 +1052,25 @@ static int effect_create(lua_State *s) 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)); + if (lua_isuserdata(s, 2)) + { + // being mode + Being *b = getBeing(s, 2); + if (!b) + { + raiseScriptError(s, "effect_create called on non-existent being"); + return 0; + } + Effects::show(id, m, b); + } + else + { + // positional mode + int x = lua_tointeger(s, 2); + int y = lua_tointeger(s, 3); + Effects::show(id, m, Point(x, y)); + } return 0; } |