From 5996ff324d4123d1b1c6adb1c81eb16dd5e7b466 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Mon, 7 Jul 2008 19:56:02 +0000 Subject: Implemented death listener for scripting engine. --- data/scripts/libtmw.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'data/scripts') diff --git a/data/scripts/libtmw.lua b/data/scripts/libtmw.lua index e788a59b..83e3b40b 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 -- cgit v1.2.3-70-g09d2