Paste #35344: Diff note for paste #35343

Date: 2016/08/13 18:07:59 UTC-07:00
Type: Diff Report

View Raw Paste Download This Paste
Copy Link


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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418


 DUL_colorcode_message:
   type: procedure
   debug: false
   DUL:
     author:
     - BlackCoyote
     description:
     - Encodes your message into a colour code string and back.
     -  only works with characters from a-z, 0-9, and _ !
     usage:
     - <proc[DUL_colorcode_message].context[encode/decode|<message>]>
     example:
     - <proc[DUL_colorcode_message].context[encode|my_sword_id]>
   encode:
     a: '&0&0'
     b: '&0&1'
     c: '&0&2'
     d: '&0&3'
     e: '&0&4'
     f: '&0&5'
     g: '&0&6'
     h: '&0&7'
     i: '&0&8'
     j: '&0&9'
     k: '&1&0'
     l: '&1&1'
     m: '&1&2'
     n: '&1&3'
     o: '&1&4'
     p: '&1&5'
     q: '&1&6'
     r: '&1&7'
     s: '&1&8'
     t: '&1&9'
     u: '&2&0'
     v: '&2&1'
     w: '&2&2'
     x: '&2&3'
     y: '&2&4'
     z: '&2&5'
     0: '&2&6'
     1: '&2&7'
     2: '&2&8'
     3: '&2&9'
     4: '&3&0'
     5: '&3&1'
     6: '&3&2'
     7: '&3&3'
     8: '&3&4'
     9: '&3&5'
     _: '&3&6'
   decode:
     '&0&0': a
     '&0&1': b
     '&0&2': c
     '&0&3': d
     '&0&4': e
     '&0&5': f
     '&0&6': g
     '&0&7': h
     '&0&8': i
     '&0&9': j
     '&1&0': k
     '&1&1': l
     '&1&2': m
     '&1&3': n
     '&1&4': o
     '&1&5': p
     '&1&6': q
     '&1&7': r
     '&1&8': s
     '&1&9': t
     '&2&0': u
     '&2&1': v
     '&2&2': w
     '&2&3': x
     '&2&4': y
     '&2&5': z
     '&2&6': 0
     '&2&7': 1
     '&2&8': 2
     '&2&9': 3
     '&3&0': 4
     '&3&1': 5
     '&3&2': 6
     '&3&3': 7
     '&3&4': 8
     '&3&5': 9
     '&3&6': _
   script:
   - if li@encode|decode !contains <def[1]||> {
     - debug error "DUL - No valid action specified! Must be encode or decode!"
     - determine null
     }
   - if <def[2]||> == "" {
     - debug error "DUL - No message specified to <def[1]>!"
     - determine null
     }
   - define result ""
   - if <def[1]> == encode {
     - define list <def[2].to_list>
     } else {
     - define list li@
     - define 2 <def[2].escaped.replace[&ss].with[&]>
     - repeat <def[2].length.div[4].as_int> {
       - define list <def[list].include[<def[2].substring[<def[value].mul[4].sub[4].add[1]||1>,<def[value].mul[4]>]>]>
       }
     }
   - foreach <def[list]>:
     - define result "<def[result]><script.yaml_key[<def[1]>.<def[value]>]||->"
   - determine <def[result].parse_color>
 DUL_ColorList:
   type: procedure
   debug: false
   DUL:
     author:
     - Anthony
     name:
     - ColorList
     description:
     - Return colors from input or just list all colors
     usage:
     - <proc[DUL_colorlist].context[<list/match|input>]>
     example:
     - narrate <proc[DUL_colorlist].context[list]>
     - narrate <proc[DUL_colorlist].context[match|blu]>
 
   colors:
     black: 0
     dark_blue: 1
     dark_green: 2
     dark_aqua: 3
     dark_red: 4
     dark_purple: 5
     gold: 6
     gray: 7
     dark_gray: 8
     blue: 9
     green: a
     aqua: b
     red: c
     light_purple: d
     yellow: e
     white: f
     magic: k
     bold: l
     strikethrough: m
     underline: n
     italic: o
     reset: r
 
   script:
     - define colors '<script.list_keys[colors]>'
     - choose '<def[1]>':
       - case 'list':
         - define list 'li@'
         - foreach '<def[colors]>':
           - define list '<def[list].include[<el@val[&<script.yaml_key[colors.%value%]>]> %value%]>'
         - determine '<def[list]>'
       - case 'match':
         - determine '<proc[DUL_find_best_match].context[<def[colors]>|<def[2]>]>'
 DUL_find_best_match:
   type: procedure
   debug: false
   DUL:
     author:
     - BlackCoyote
     - Anthony
     description:
     - Returns the best search match out of a list.
     usage:
     - <proc[DUL_find_best_match].context[<list>|<value>]>
     example:
     - <proc[DUL_find_best_match].context[<server.flag[homes].as_list>|<context.args.get[1]>]>
   script:
   - define l '<queue.definitions.numerical>'
   - define list 'li@'
   - foreach '<def[l]>':
     - define list '<def[list].include[<def[%loop_index%]>]>'
   - define match '<def[list].last>'
   - define list '<def[list].remove[<def[list].size>]>'
   - if <def[list].is_empty||true> {
     - debug error "DUL - No valid list specified!"
     - determine null
     }
   - if <def[match]||null> == null {
     - debug error "DUL - No valid value specified!"
     - determine null
     }
   - if <def[list].contains[<def[match]>]> {
     - determine <def[match]>
     } else if <def[list].filter[starts_with[<def[match]>]].size||0> > 0 {
     - determine <def[list].filter[starts_with[<def[match]>]].sort_by_number[length].first||null>
     } else if <def[list].filter[contains[<def[match]>]].size||0> > 0 {
     - determine <def[list].filter[contains[<def[match]>]].sort_by_number[length].first||null>
     } else {
     - determine null
     }
 DUL_hidden_spawn_locations:
   type: procedure
   debug: false
   definitions: location|radius
   DUL:
     author:
     - BlackCoyote
     description:
     - Finds spawn locations within range that are out of line of sight.
     - If no locations out of line of sight are found, it will return valid spawn locations within line of sight.
     usage:
     - <proc[DUL_hidden_spawn_locations].context[<l@location>|<radius>]>
     example:
     - <proc[DUL_hidden_spawn_locations].context[<player.location>|15]>
   script:
   - if <def[location]||null> !matches location {
     - debug error "DUL - No valid location specified!"
     - determine null
     }
   - if <def[radius]||null> !matches number {
     - debug error "DUL - No valid radius specified!"
     - determine null
     }
   - define radius <def[radius].as_int>
   - determine <def[location].find.surface_blocks.within[<def[radius]>].filter[y.sub[<def[location].y>].abs.is[less].than[3]].filter[above.above.above.material.name.is[==].to[air]].filter[above.above.above.above.material.name.is[==].to[air]].filter[above.above.above.above.above.material.name.is[==].to[air]].filter[material.is_occluding].parse[above].filter[above.center.line_of_sight[<def[location].add[0,1.5,0].center>].not]||<def[location].find.surface_blocks.within[<def[radius]>]||li@<def[location]>>>
 DUL_rainbow_text:
   type: procedure
   debug: false
   DUL:
     author:
     - BlackCoyote
     description:
     - Turns the colour of a text into a rainbow format with a new colour per letter.
     usage:
     - <proc[DUL_rainbow_text].context[<text.escaped>]>
     example:
     - <proc[DUL_rainbow_text].context[<context.message.escaped>]>
   script:
   - if <def[1].exists.not> {
     - debug error "DUL - No valid text specified!"
     - determine null
     }
   - define colormap li@&4|&6|&e|&a|&3|&9|&5
   - define result ""
   - foreach <def[1].unescaped.to_list.escape_contents>:
-    - define result "<def[result]><def[colormap].get[<def[loop_index].sub[1].mod[7].add[1].as_int>]><def[value]>"
-  - determine <def[result].parse_color>
+    - define result "<def[result]><def[colormap].get[<def[loop_index].sub[1].mod[7].add[1].as_int>].parse_color><def[value]>"
+  - determine <def[result]>
 DUL_random_surface_block:
   type: procedure
   definitions: location|radius
   debug: false
   DUL:
     author:
     - BlackCoyote
     description:
     - Finds a random surface block within the provided radius more efficiently than conventional denizen tags.
     usage:
     - <proc[DUL_random_surface_block].context[<l@location>|<radius>]>
     example:
     - <proc[DUL_random_surface_block].context[<player.location>|5000]>
   script:
   - if <def[location]||null> !matches location {
     - debug error "DUL - No valid location specified!"
     - determine null
     }
   - if <def[radius]||null> !matches number {
     - debug error "DUL - No valid radius specified!"
     - determine null
     }
   - while true:
     - define newloc <def[location].add[<util.random.int[<def[radius].mul[-1]>].to[<def[radius]>]>,0,<util.random.int[<def[radius].mul[-1]>].to[<def[radius]>]>].highest.find.surface_blocks.within[5].get[1]||null>
     - if <def[newloc]> != null && <def[newloc].material.is_occluding> {
       - determine <def[newloc].above>
       } else if <def[loop_index]> >= 10 {
       - determine null
       }
 DUL_safeString:
   type: procedure
   debug: false
   DUL:
     author:
     - Anthony
     name:
     - Safe String
     description:
     - Boolean tag returns true if the string only contains lower case letters, numbers, and/or underscore _
     usage:
     - <proc[DUL_safeString].context[string]>
     example:
     - narrate <proc[DUL_safeString].context[check_this_string]>
   script:
     - determine '<def[1].matches[^[a-z0-9-_]+$]>'
 
 DUL_cleanString:
   type: procedure
   debug: false
   DUL:
     author:
     - Anthony
     name:
     - Clean String
     description:
     - Clean a string of any character that is not a lower case letter, number, or underscore _
     usage:
     - <proc[DUL_cleanString].context[string]>
     example:
     - narrate <proc[DUL_cleanString].context[cleanA_thi&s_string]>
   script:
     - determine '<def[1].replace[regex:[^a-z0-9-_]]>'
 
 
 
 #
 DUL_script_tracker:
   type: world
   debug: false
   events:
     on system time hourly:
     - webget "http://morphanone.space/webizen.aspx/tracker?script=96&version=<s@DUL_version_script.yaml_key[version]>"
 DUL_text_progress_bar:
   type: procedure
   debug: false
   DUL:
     author:
     - BlackCoyote
     description:
     - Makes a text based progress bar based on the percentage you provide.
     usage:
     - <proc[DUL_text_progress_bar].context[<percentage>(|<size>|<character>|<color1>|<color2>)]>
     example:
     - <proc[DUL_text_progress_bar].context[<player.health.percentage>]>
   script:
   - define percentage <def[1]||0>
   - if <def[percentage].as_int||none> == none {
     - define percentage 0
     }
   - if <def[2].exists> {
     - define max <def[2]>
     }
   - if <def[max].as_int||none> == none {
     - define max 10
     }
   - if <def[3].exists> {
     - define char <def[3].substring[1,1]||=>
     } else {
     - define char =
     }
   - if <def[4].exists> {
     - define col1 <def[4]>
     } else {
     - define col1 &a
     }
   - if <def[5].exists> {
     - define col2 <def[5]>
     } else {
     - define col2 &7
     }
   - define string <el@.pad_right[<def[max]>].with[<def[char]>]>
   - define split <def[max].div[100].mul[<def[percentage]>].as_int>
   - determine "<def[col1].parse_colors><def[string].substring[1,<def[split]>]><def[col2].parse_colors><def[string].substring[<def[split].add[1].as_int>,<def[max]>]>"
 DUL_unique_queue_id_prefixed:
   type: procedure
   debug: false
   DUL:
     author:
     - BlackCoyote
     description:
     - Gives a unique queue ID for you to use, with a specified prefix.
     usage:
     - <proc[DUL_unique_queue_id_prefixed].context[<prefix>]>
     example:
     - <proc[DUL_unique_queue_id_prefixed].context[DUL_<player>]>
   script:
   - define prefix <def[1]||>
   - define id <def[prefix]><util.random.duuid>
   - while <queue.list.parse[id].contains[<def[id]>]>:
     - define id <def[prefix]><util.random.duuid>
   - determine <def[id]>
 DUL_version_script:
   type: version
   name: dUtilLib
   id: 96
   description: A collection of dscript functions and utilities written by BlackCoyote and Anthony.
   version: 8
 DUL_WRCG:
   type: procedure
   debug: false
   DUL:
     author:
     - Anthony
     name:
     - Weighted Random Choice Generator
     description:
     - Supply a list of weight/return values and have one of the values returned to you randomly based on weight.
     usage:
     - <proc[DUL_WRCG].context[weight/return|...]>
     example:
     - give <proc[DUL_WRCG].context[10/i@apple|1/i@gold_ingot|20/i@stone]>
   script:
     - define l 'li@'
     - foreach '<queue.definitions.exclude[l]>':
       - define l '<def[l].include[<def[%value%]>]>'
     - define w '0'
     - foreach '<def[l].parse[before[/]]>':
       - define w '<def[w].add[%value%]>'
     - define number '<util.random.int[1].to[%w%]>'
     - define hv '0'
     - foreach '%l%':
       - define ov '%hv%'
       - define lv '<def[ov].add[1]>'
       - define hv '<def[ov].add[<def[value].before[/]>]>'
       - if %number% >= %lv% && %number% <= %hv% {
         - determine '<def[value].after[/]>'
         }
-