From 37adb26ef191f5897aa77b59f2efe9474b7d2e56 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Wed, 4 Apr 2012 21:40:13 +0200 Subject: Adding monster::on_damage callback Reviewed-by: bjorn --- src/scripting/lua.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 1900f5ac..ca4a3272 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -1267,6 +1267,14 @@ static int monster_class_on_update(lua_State *s) return 0; } +static int monster_class_on_damage(lua_State *s) +{ + MonsterClass *monsterClass = LuaMonsterClass::check(s, 1); + luaL_checktype(s, 2, LUA_TFUNCTION); + monsterClass->setDamageCallback(getScript(s)); + return 0; +} + static int monster_class_on(lua_State *s) { MonsterClass *monsterClass = LuaMonsterClass::check(s, 1); @@ -2492,6 +2500,7 @@ LuaScript::LuaScript(): static luaL_Reg const members_MonsterClass[] = { { "on_update", &monster_class_on_update }, + { "on_damage", &monster_class_on_damage }, { "on", &monster_class_on }, { NULL, NULL } }; -- cgit v1.2.3-70-g09d2