-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqemistry.trigger
81 lines (76 loc) · 2.61 KB
/
qemistry.trigger
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MudletPackage>
<MudletPackage version="1.0">
<TriggerPackage/>
<TimerPackage/>
<AliasPackage>
<Alias isActive="yes" isFolder="no">
<name>testQem</name>
<script>balQueue = Qemistry.Queue("balance", "my_sys.bal")
balQueue:Add( {
code = {
function () echo("bal 100\n") end,
function () my_sys.bal = false; my_sys.eq = true end,
function () eqQueue:Do() end,
},
consumed = "my_sys.bal"
} )
for i = 1, 99 do
balQueue:Add( function () echo("bal " .. i .. "\n") end )
end
balQueue:Add( function () echo("Final call.\n") end )
eqQueue = Qemistry.Queue("eq", "my_sys.eq")
eqQueue:Add( function () my_sys.bal = true end )
for i = 1, 99, 2 do
eqQueue:Add( {code = function () balQueue:Add("eq " .. i .. "\n") end, required = function () return my_sys.bal end} )
end
eqQueue:Add( function () balQueue:Do() end )
--display( Qemistry.Queues )
echo("Test ready.\n")</script>
<command></command>
<packageName></packageName>
<regex>^tq$</regex>
</Alias>
<Alias isActive="yes" isFolder="no">
<name>balQueue</name>
<script>balQueue:Do()</script>
<command></command>
<packageName></packageName>
<regex>^bq$</regex>
</Alias>
<Alias isActive="yes" isFolder="no">
<name>eqQueue</name>
<script>eqQueue:Do()</script>
<command></command>
<packageName></packageName>
<regex>^eq$</regex>
</Alias>
</AliasPackage>
<ActionPackage/>
<ScriptPackage>
<Script isActive="yes" isFolder="no">
<name>Qemistry</name>
<packageName></packageName>
<script>if not Qemistry then
echo("Qemistry: Loading module...\n")
local path = package.path
local home_dir = getMudletHomeDir()
local lua_dir = string.format( "%s/%s", home_dir, [[?.lua]] )
local init_dir = string.format( "%s/%s", home_dir, [[?/init.lua]] )
package.path = string.format( "%s;%s;%s", path, lua_dir, init_dir )
local okay, content = pcall( require, "qemistry" )
package.path = path
if okay then
Qemistry = content
else
error(string.format("Qemistry: Error loading module: %s\n", content))
end
if Qemistry then
echo("Qemistry: Module successfully loaded.\n")
end
end</script>
<eventHandlerList/>
</Script>
</ScriptPackage>
<KeyPackage/>
</MudletPackage>