|
@@ -0,0 +1,28 @@
|
|
1
|
+local pkg = {}
|
|
2
|
+
|
|
3
|
+pkg.STATE = {}
|
|
4
|
+
|
|
5
|
+pkg.SET = function(loader, ruleset)
|
|
6
|
+ pkg.STATE.loader = loader or function() return true end
|
|
7
|
+ pkg.STATE.ruleset = ruleset or {}
|
|
8
|
+ return true
|
|
9
|
+end
|
|
10
|
+
|
|
11
|
+pkg.RUN = function()
|
|
12
|
+ local i
|
|
13
|
+ for _, rule in ipairs(pkg.STATE.ruleset) do
|
|
14
|
+ i = rule.loader()
|
|
15
|
+ if not i then return end
|
|
16
|
+ rule.action(i)
|
|
17
|
+ end
|
|
18
|
+ pkg.SET()
|
|
19
|
+end
|
|
20
|
+
|
|
21
|
+pkg.ADD = function(action, loader)
|
|
22
|
+ local rule = {}
|
|
23
|
+ rule.action = action
|
|
24
|
+ rule.loader = loader or pkg.STATE.loader
|
|
25
|
+ table.insert(pkg.STATE, rule)
|
|
26
|
+end
|
|
27
|
+
|
|
28
|
+return pkg
|