diff options
| author | Philipp Sehmisch <tmw@crushnet.org> | 2008-07-07 19:56:02 +0000 |
|---|---|---|
| committer | Philipp Sehmisch <tmw@crushnet.org> | 2008-07-07 19:56:02 +0000 |
| commit | 5996ff324d4123d1b1c6adb1c81eb16dd5e7b466 (patch) | |
| tree | 92943ff0856aa4ed4accd04d9e870d96cf186a21 /data/scripts/libtmw.lua | |
| parent | e5d4c719a52d03bfe9bfb4ea2fea0570842985bc (diff) | |
Implemented death listener for scripting engine.
Diffstat (limited to 'data/scripts/libtmw.lua')
| -rw-r--r-- | data/scripts/libtmw.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/data/scripts/libtmw.lua b/data/scripts/libtmw.lua index e788a59..83e3b40 100644 --- a/data/scripts/libtmw.lua +++ b/data/scripts/libtmw.lua @@ -322,6 +322,25 @@ function schedule_every(seconds, funct) end +-- DEATH NOTIFICATIONS +local ondeath_functs = {} + +function onDeath(being, funct) + if ondeath_functs[being] == nil then + ondeath_functs[being] = {} + end + table.insert(ondeath_functs[being], funct) + tmw.noteOnDeath(being) +end + +function deathNotification(being) + if type(ondeath_functs[being]) == "table" then + for i,funct in pairs(ondeath_functs[being]) do + funct() + end + end +end + -- Below are some convenience methods added to the engine API |
