summaryrefslogtreecommitdiffhomepage
path: root/not/Trigger.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-14 16:23:07 +0200
committerAki <nthirtyone@gmail.com>2017-09-14 16:23:07 +0200
commit31c994c223c0a9a63d503d43877254268f52811c (patch)
tree0ee96bbc19f95e172da8c24fe73cbf2d946301a0 /not/Trigger.lua
parentee0438e346d17be68a4b57dec62e7279f40bfefd (diff)
downloadroflnauts-31c994c223c0a9a63d503d43877254268f52811c.zip
roflnauts-31c994c223c0a9a63d503d43877254268f52811c.tar.gz
roflnauts-31c994c223c0a9a63d503d43877254268f52811c.tar.bz2
Added Timer and Trigger classes
Diffstat (limited to 'not/Trigger.lua')
-rw-r--r--not/Trigger.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/not/Trigger.lua b/not/Trigger.lua
new file mode 100644
index 0000000..c6ef7c7
--- /dev/null
+++ b/not/Trigger.lua
@@ -0,0 +1,18 @@
+Trigger = require "not.Object":extends()
+
+function Trigger:new ()
+ self.calls = {}
+end
+
+function Trigger:register (func, ...)
+ local call = {func = func, params = {...}}
+ table.insert(self.calls, call)
+end
+
+function Trigger:emit ()
+ for _,call in pairs(self.calls) do
+ call.func(unpack(call.params))
+ end
+end
+
+return Trigger