-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchaosinit.ks
62 lines (49 loc) · 1.34 KB
/
chaosinit.ks
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
// chaosinit.ks
@lazyglobal off.
clearscreen.
cd("1:/chaos/").
global chaOSconfig is lexicon("startTime", time:seconds, "quit", false).
init().
if exists("1:/chaos/savedata/config.txt") = false {
firstruninit().
}
if exists("1:/chaos/savedata/queues.dat") {
revertfromsave().
}
startup().
function firstruninit {
print "Beginning first setup".
copypath("0:/chaos/savedata/", "1:/chaos/savedata/").
}
function init {
runoncepath("1:/chaos/modules/modulemanager").
module:ui:makeActiveGUI().
test().
}
function startup {
until chaOSconfig:quit {
module:processmanager:iterateOverQueues().
if mod(updatecycle,20) = 0 { module:savestate:saveCurrentState(). }
wait 0.
}.
module:ui:gui:dispose().
cd("1:/chaos/").
}
function POST {
parameter testval.
module:ui:debug("This is a " + testval + " message").
module:ui:debug("My PID is: " + self:PID).
return "This is a test return".
}
function test {
local processPID is module:processmanager:spawnTask(
module:utilities:delegate(POST@), 1, list("test")):PID.
module:processmanager:spawnListener(
module:utilities:stringFunction("if time:seconds >= 10 + " + time:seconds + " return true. return false."),
module:utilities:stringFunction("module:ui:debug('Listener has fired!')."),
0, list()).
module:ui:debug("Done!").
}
function revertfromsave {
module:savestate:loadSavedState().
}