summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2008-07-07 20:14:20 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2008-07-07 20:14:20 +0000
commit53167ad7742070c8dabc26e7fdc8beae507748a9 (patch)
tree46f7d4c3f6b403a2174e8241687d4529bd6a0bec
parent5996ff324d4123d1b1c6adb1c81eb16dd5e7b466 (diff)
downloadmanaserv-53167ad7742070c8dabc26e7fdc8beae507748a9.tar.gz
manaserv-53167ad7742070c8dabc26e7fdc8beae507748a9.tar.bz2
manaserv-53167ad7742070c8dabc26e7fdc8beae507748a9.tar.xz
manaserv-53167ad7742070c8dabc26e7fdc8beae507748a9.zip
changed function naming to be consistent with the rest of the script API and improved commenting.
-rw-r--r--data/scripts/libtmw.lua10
-rw-r--r--data/test.lua10
-rw-r--r--src/scripting/lua.cpp6
3 files changed, 15 insertions, 11 deletions
diff --git a/data/scripts/libtmw.lua b/data/scripts/libtmw.lua
index 83e3b40b..26fb4ed3 100644
--- a/data/scripts/libtmw.lua
+++ b/data/scripts/libtmw.lua
@@ -325,15 +325,19 @@ end
-- DEATH NOTIFICATIONS
local ondeath_functs = {}
-function onDeath(being, funct)
+-- requests the gameserver to notify the script engine when the being
+-- dies and adds a script function to be executed in this case.
+function on_death(being, funct)
if ondeath_functs[being] == nil then
ondeath_functs[being] = {}
end
table.insert(ondeath_functs[being], funct)
- tmw.noteOnDeath(being)
+ tmw.note_on_death(being)
end
-function deathNotification(being)
+-- called by the engine when a being with dies for which a death
+-- notification has been requested
+function death_notification(being)
if type(ondeath_functs[being]) == "table" then
for i,funct in pairs(ondeath_functs[being]) do
funct()
diff --git a/data/test.lua b/data/test.lua
index 75a903ed..cd624822 100644
--- a/data/test.lua
+++ b/data/test.lua
@@ -125,11 +125,11 @@ function npc5_talk(npc, ch)
m3 = tmw.monster_create(1, x + TILESIZE, y - TILESIZE)
m4 = tmw.monster_create(1, x - TILESIZE, y - TILESIZE)
- onDeath(m1, function() tmw.being_say(npc, "NOOO!") end)
- onDeath(m2, function() tmw.being_say(npc, "Please stop this violence!") end)
- onDeath(m3, function() tmw.being_say(npc, "Stop slaughtering my scorpions!") end)
- onDeath(m4, function() tmw.being_say(npc, "Leave my scorpions alone!") end)
- onDeath(m4, function() tmw.being_say(m4, "AAARGH!") end)
+ on_death(m1, function() tmw.being_say(npc, "NOOO!") end)
+ on_death(m2, function() tmw.being_say(npc, "Please stop this violence!") end)
+ on_death(m3, function() tmw.being_say(npc, "Stop slaughtering my scorpions!") end)
+ on_death(m4, function() tmw.being_say(npc, "Leave my scorpions alone!") end)
+ on_death(m4, function() tmw.being_say(m4, "AAARGH!") end)
end
end
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 5a9364db..38f5cd25 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -726,7 +726,7 @@ static int LuaGetBeingsInCircle(lua_State *s)
/**
* Makes the server call the lua function deathEvent
* with the being ID when the being dies.
- * tmw.noteOnDeath (being)
+ * tmw.note_on_death (being)
*/
static int LuaNoteOnDeath(lua_State *s)
{
@@ -776,7 +776,7 @@ LuaScript::LuaScript():
{ "trigger_create", &LuaTrigger_Create },
{ "chatmessage", &LuaChatmessage },
{ "get_beings_in_circle", &LuaGetBeingsInCircle},
- { "noteOnDeath", &LuaNoteOnDeath },
+ { "note_on_death", &LuaNoteOnDeath },
{ NULL, NULL }
};
luaL_register(mState, "tmw", callbacks);
@@ -867,7 +867,7 @@ void LuaScript::load(char const *prog)
void LuaScript::processDeathEvent(Being *being)
{
- prepare("deathNotification");
+ prepare("death_notification");
push(being);
//TODO: get and push a list of creatures who contributed to killing the
// being. This might be very interesting for scripting quests.