-
-
Notifications
You must be signed in to change notification settings - Fork 103
/
util.dscript
108 lines (85 loc) · 3.2 KB
/
util.dscript
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# /dTime Command
_util_dtime_command:
type: world
events:
on dtime command:
- if !<player.is_op> queue clear
- flag 'ddtc_time:<context.args.get[1]>'
- if <flag.p:ddtc_time> > 24
queue clear
else narrate 'Changing time to <flag.p:ddtc_time>:00.'
- if <flag.p:ddtc_time> == 24
execute as_op 'time set 18000'
- flag ddtc_time:-:6
- if <flag.p:ddtc_time> >= 0
execute as_op 'time set <flag.p:ddtc_time.asint>000'
- flag ddtc_time:+:24
- if <flag.p:ddtc_time> > 18
execute as_op 'time set <flag.p:ddtc_time.asint>000'
- flag ddtc_time:!
- determine cancelled
# Generic Looper (GL)
"loop through":
type: task
speed: 0
context: task|flag|type
script:
- ^if %3% == global || <context.type> == global ^define 3 server
else ^define 3 <context.type>
- ^define queue <util.random.uuid>
- ^if %1% != null
^run '_depend generic loop process' id:%queue% "def:%1%|%2%|%3%|%queue%" instantly
else ^run '_depend generic loop process'
"def:<context.task>|<context.flag>|%3%|%queue%" instantly
"_util_gl":
type: task
speed: 0
context: task|flag|type
script:
- if %1% != null
run '_depend generic loop process' id:<util.random.uuid> "def:%1%|%2%|%3%|<util.random.uuid>" instantly
else run '_depend generic loop process'
"def:<context.task>|<context.flag>|<context.type>|<util.random.uuid>" instantly
"_depend generic loop process":
type: task
definitions: task|flag|type|id
script:
- ^if "<server.flag[Iterator %id%]>" == null
^flag global "Iterator %id%:|:<%type%.flag[%flag%].aslist>"
- ^runtask "%task%" "context:<server.flag[Iterator %id%].get[1]>" queue instantly
- ^flag global "Iterator %id%:<-:<server.flag[Iterator %id%].get[1]>"
- ^if "<server.flag[Iterator %id%].size || 0>" > 0
run instantly '_depend Generic Loop Process' id:%id%
"def:%task%|%flag%|%type%|%id%"
else flag global "Iterator %id%:!"
# Load Tester
Load Tester:
type: world
events:
on testload command:
# ops only!
- if !<player.is_op> queue clear
- if <c.args.size> == 1
define n <c.args.get[1]>
# if no number specified, stress test with 100 queues
- if %n% == null {
- narrate 'Invalid integer, assuming 100.'
- define n 100
}
# initialize the progress flag
# this will count up each time a queue was completed
- flag server stress_test_counter:0
# keep track of the start time
- define start_time <server.current_time_millis>
# repeat the run command
# each run will create a new queue, and increase the counter
- repeat %n% {
- flag server stress_test_counter:++
}
# ...and end time, to compare against the start time
- define end_time <server.current_time_millis>
- narrate 'Completed <server.flag[stress_test_counter].as_int> of %n%
total queues in <m:(%end_time% - %start_time%) / 1000> seconds.'
# cleanup
- flag server stress_test_counter:!
- determine fulfilled