-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.html
More file actions
569 lines (480 loc) · 18.4 KB
/
parser.html
File metadata and controls
569 lines (480 loc) · 18.4 KB
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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<title>Hello, world!</title>
<style>
.red {
color: #eb3b5a;
}
.yellow {
color: #fed330;
}
.purple {
color: #a55eea;
}
.dark-gray {
color: #778ca3;
}
.orange {
color: #fa8231;
}
.cyan {
color: #0fb9b1;
}
.gray {
color: #a5b1c2;
}
.green {
color: #26de81;
}
.dark-green {
color: #20bf6b;
}
.blue {
color: #45aaf2;
}
.dark-blue {
color: #4b7bec;
}
pre {
background: rgb(22, 30, 39);
color: #a5b1c2;
}
</style>
</head>
<body>
<pre>
options:
name : GameAPI
version : 1.3
function send(test: string):: player:
send " " to console
send "&a[{@name}] &e-_-_-_-_-_-_-_-_ &a{@name} &e-_-_-_-_-_-_-_-_" to console
send "&a[{@name}]" to console
send "&a[{@name}] Version {@version}" to console
send "&a[{@name}] by AlexLew" to console
send "&a[{@name}] Documentation : https://github.com/AlexLew95/GameAPI/wiki/Syntax" to console
send " " to console
send "&a[{@name}] &eYour addons > &f%addons list%" to console
send " " to console
on load:
if line 1 from url "https://raw.githubusercontent.com/AlexLew95/GameAPI/master/version" is not "{@version}":
send "&a[{@name}] New version avaible!" to console
on skript load:
if file "plugins/{@name}" is a dir:
create dir "plugins/{@name}"
send()
on command "/ver GameAPI" or "/version GameAPI":
If sender is a player:
If sender is op:
send "&a[{@name}] Version {@version}" to sender
send "&a[{@name}] by AlexLew" to sender
send "&a[{@name}] Documentation : https://github.com/AlexLew95/GameAPI/wiki/Syntax" to sender
#Load minis-games
effect load mini[s]( |-)game[s] [named] %string%:
set {_namemg} to expression-1
if yaml "%{_namemg}%" is not loaded:
load yaml "plugins/GameAPI/%{_namemg}%.yml" as "%{_namemg}%"
#Create a team
effect create [a] team named %string% for [[the] mini[s](-| )game[s]] %string%:
set {_name} to expression-1
set {_min} to expression-2
set {_max} to expression-3
set {_namemg} to expression-4
if yaml "%{_namemg}%" is loaded:
set {_listnodes::*} to yaml nodes "GameAPI.%{_namemg}%.Teams" from "%{_namemg}%"
if "%{_listnodes::*}%" is "<none>" or "":
set {_id} to 0
else:
set {_id} to amount of {_listnodes::*}
set skript-yaml value "GameAPI.%{_namemg}%.Teams.Team %{_name}%.Name" from "%{_namemg}%" to "%{_name}%"
set skript-yaml value "GameAPI.%{_namemg}%.Teams.Team %{_name}%.ID" from "%{_namemg}%" to "%{_id}%"
save yaml "%{_namemg}%"
set {_details::*} to {_name}, {_min}, {_max} and {_namemg}
call custom event "team created" to details {_details::*}
#Remove a team
effect remove [the] team named %string% from [[the] mini[s](-| )game[s]] %string%:
set {_name} to expression-1
set {_namemg} to expression-2
if yaml "%{_namemg}%" is loaded:
delete skript-yaml list "GameAPI.%{_namemg}%.Teams.Team %{_name}%" from "%{_namemg}%"
save yaml "%{_namemg}%"
set {_details::*} to {_name} and {_namemg}
call custom event "team deleted" to details {_details::*}
#Create a mini game
effect create [a] mini game named %string%:
set {_namemg} to expression-1
set {_min} to expression-2
set {_max} to expression-3
if file "plugins/GameAPI/%{_namemg}%.yml" doesn't exist:
create file "plugins/GameAPI/%{_namemg}%.yml"
load yaml "plugins/GameAPI/%{_namemg}%.yml" as "%{_namemg}%"
set {_details::*} to {_min}, {_max} and {_namemg}
call custom event "mini game created" to details {_details::*}
#Remove a mini game
effect remove [the] mini game %string%:
set {_name} to expression-1
set {_namemg} to expression-2
if yaml "%{_namemg}%" is loaded:
unload yaml "%{_namemg}%"
delete file "%{_namemg}%"
set {_details::*} to {_name} and {_namemg}
call custom event "mini game deleted" to details {_details::*}
#Set minimum of player in a mini game
effect set [the] min[imum] [of] player (from|of) [[the] mini[s](-| )game[s]] %string% to %integer%:
set {_min} to expression-1
set {_namemg} to expression-2
if yaml "%{_namemg}%" is loaded:
set skript-yaml value "GameAPI.%{_namemg}%.Minimum player" from "%{_namemg}%" to "%{_min}%"
save yaml "%{_namemg}%"
set {_details::*} to {_min} and {_namemg}
call custom event "minimum player set in mini-game" to details {_details::*}
#Set maximum of player in a mini game
effect set [the] max[imum] [of] player (from|of) [[the] mini[s](-| )game[s]] %string% to %integer%:
set {_max} to expression-1
set {_namemg} to expression-2
if yaml "%{_namemg}%" is loaded:
set skript-yaml value "GameAPI.%{_namemg}%.Maximum player" from "%{_namemg}%" to "%{_max}%"
save yaml "%{_namemg}%"
set {_details::*} to {_max} and {_namemg}
call custom event "maximum player set in mini-game" to details {_details::*}
#Set minimum of player in a team of a mini game
effect set [the] min[imum] [of] player (of|from) %string% (from|of) [[the] mini[s](-| )game[s]] %string% to %integer%:
set {_min} to expression-1
set {_name} to expression-2
set {_namemg} to expression-3
if yaml "%{_namemg}%" is loaded:
set skript-yaml value "GameAPI.%{_namemg}%.Teams.Team %{_name}%.Minimum player" from "%{_namemg}%" to "%{_min}%"
save yaml "%{_namemg}%"
set {_details::*} to {_min}, {_name} and {_namemg}
call custom event "minimum player set in team" to details {_details::*}
#Set maximum of player in a team of a mini game
effect set [the] max[imum] [of] player (of|from) %string% (from|of) [[the] mini[s](-| )game[s]] %string% to %integer%:
set {_min} to expression-1
set {_name} to expression-2
set {_namemg} to expression-3
if yaml "%{_namemg}%" is loaded:
set skript-yaml value "GameAPI.%{_namemg}%.Teams.Team %{_name}%.Maximum player" from "%{_namemg}%" to "%{_max}%"
save yaml "%{_namemg}%"
set {_details::*} to {_min}, {_name} and {_namemg}
call custom event "maximum player set in in team" to details {_details::*}
#Join a team
effect make %player% join [[the] team] %string% (from|of) [[the] mini[s](-| )game[s]] %string%:
set {_player} to expression-1
set {_name} to expression-2
set {_namemg} to expression-3
if yaml "%{_namemg}%" is loaded:
set {_listnodes::*} to skript-yaml nodes "GameAPI.%{_namemg}%.Teams" from "%{_namemg}%"
loop {_listnodes::*}:
set {_listplayer::*} to skript-yaml list "GameAPI.%{_namemg}%.Teams.%loop-value%.Players" from "%{_namemg}%"
If {_listplayer::*} contains "%{_player}%":
remove "%{_player}%" from skript-yaml list "GameAPI.%{_namemg}%.Teams.Team %{_name}%.Players" from "%{_namemg}%"
exit loop
add "%{_player}%" to skript-yaml list "GameAPI.%{_namemg}%.Teams.Team %{_name}%.Players" from "%{_namemg}%"
save yaml "%{_namemg}%"
set {_details::*} to {_player}, {_name} and {_namemg}
call custom event "player joined team" to details {_details::*}
#Leave a team
effect make %player% leave [[the] team] %string% (from|of) [[the] mini[s](-| )game[s]] %string%:
set {_player} to expression-1
set {_name} to expression-2
set {_namemg} to expression-3
if yaml "%{_namemg}%" is loaded:
set {_listnodes::*} to skript-yaml nodes "GameAPI.%{_namemg}%.Teams" from "%{_namemg}%"
loop {_listnodes::*}:
set {_listplayer::*} to skript-yaml list "GameAPI.%{_namemg}%.Teams.%loop-value%.Players" from "%{_namemg}%"
If {_listplayer::*} contains "%{_player}%":
remove "%{_player}%" from skript-yaml list "GameAPI.%{_namemg}%.Teams.Team %{_name}%.Players" from "%{_namemg}%"
exit loop
save yaml "%{_namemg}%"
set {_details::*} to {_player}, {_name} and {_namemg}
call custom event "player left team" to details {_details::*}
#Join a mini game
effect make %player% join [the] mini game %string%:
set {_player} to expression-1
set {_namemg} to expression-2
if yaml "%{_namemg}%" is loaded:
set {_listplayer::*} to skript-yaml list "GameAPI.%{_namemg}%.Players" from "%{_namemg}%"
If {_listplayer::*} contains "%{_player}%":
remove "%{_player}%" from skript-yaml list "GameAPI.%{_namemg}%.Players" from "%{_namemg}%"
add "%{_player}%" to skript-yaml list "GameAPI.%{_namemg}%.Players" from "%{_namemg}%"
save yaml "%{_namemg}%"
set {_details::*} to {_player} and {_namemg}
call custom event "player joined mini game" to details {_details::*}
#Leave a mini game
effect make %player% leave [the] mini game %string%:
set {_player} to expression-1
set {_namemg} to expression-2
if yaml "%{_namemg}%" is loaded:
set {_listnodes::*} to skript-yaml nodes "GameAPI.%{_namemg}%.Teams" from "%{_namemg}%"
loop {_listnodes::*}:
set {_listplayer::*} to skript-yaml list "GameAPI.%{_namemg}%.Teams.%loop-value%.Players" from "%{_namemg}%"
If {_listplayer::*} contains "%{_player}%":
remove "%{_player}%" from skript-yaml list "GameAPI.%{_namemg}%.Teams.Team %{_name}%.Players" from "%{_namemg}%"
exit loop
save yaml "%{_namemg}%"
set {_details::*} to {_player} and {_namemg}
call custom event "player left mini game" to details {_details::*}
#Random Team
get expression [a] random team (from|of) [[the] mini[s](-| )game[s]] %string%:
set {_namemg} to expression-1
if yaml "%{_namemg}%" is loaded:
set {_listnodes::*} to skript-yaml nodes "GameAPI.%{_namemg}%.Teams" from "%{_namemg}%"
replace all "Team " with "" in {_listnodes::*}
set {_random} to a random element of {_listnodes::*}
continue "%{_random}%"
else:
continue false
#Add Team Points
effect add %integer% point[s] for [[the] team] %string% (from|of) [[the] mini[s](-| )game[s]] %string%:
set {_integer} to expression-1
set {_name} to expression-2
set {_namemg} to expression-3
if yaml "%{_namemg}%" is loaded:
set {_points} to skript-yaml value "GameAPI.%{_namemg}%.Teams.Team %{_name}%.Points" from "%{_namemg}%"
set {_points} to {_points} parsed as number
set {_points2} to {_points} + {_integer}
set skript-yaml value "GameAPI.%{_namemg}%.Teams.Team %{_name}%.Points" from "%{_namemg}%" to "%{_points2}%"
set {_details::*} to {_integer}, {_name} and {_namemg}
call custom event "team won points" to details {_details::*}
#Remove Team Points
effect remove %integer% point[s] from [[the] team] %string% (from|of) [[the] mini[s](-| )game[s]] %string%:
set {_integer} to expression-1
set {_name} to expression-2
set {_namemg} to expression-3
if yaml "%{_namemg}%" is loaded:
set {_points} to skript-yaml value "GameAPI.%{_namemg}%.Teams.Team %{_name}%.Points" from "%{_namemg}%"
set {_points} to {_points} parsed as number
set {_points2} to {_points} - {_integer}
set skript-yaml value "GameAPI.%{_namemg}%.Teams.Team %{_name}%.Points" from "%{_namemg}%" to "%{_points2}%"
set {_details::*} to {_integer}, {_name} and {_namemg}
call custom event "team lost points" to details {_details::*}
#Reset Team Points
effect reset point[s] for [[the] team] %string% (from|of) [[the] mini[s](-| )game[s]] %string%:
set {_integer} to expression-1
set {_name} to expression-2
set {_namemg} to expression-3
if yaml "%{_namemg}%" is loaded:
set skript-yaml value "GameAPI.%{_namemg}%.Teams.Team %{_name}%.Points" from "%{_namemg}%" to "0"
set {_details::*} to {_integer}, {_name} and {_namemg}
call custom event "team's reset points" to details {_details::*}
#Set spawn of a team
effect set spawn of [[the] team] %string% from [[the] mini game] %string% to %location%:
set {_name} to expression-1
set {_namemg} to expression-2
set {_location} to expression-3
if yaml "%{_namemg}%" is loaded:
set skript-yaml value "GameAPI.%{_namemg}%.Teams.Team %{_name}%.Spawn" from "%{_namemg}%" to "%{_location}%"
set {_details::*} to {_name}, {_location} and {_namemg}
call custom event "team spawn set" to details {_details::*}
call custom event "spawn set" to details {_details::*}
#Set spawn of a mini-game
effect set spawn of [[the] mini game] %string% to %location%:
set {_namemg} to expression-1
if yaml "%{_namemg}%" is loaded:
set skript-yaml value "GameAPI.%{_namemg}%.Spawn" from "%{_namemg}%" to "%{_location}%"
set {_details::*} to {_name}, {_location} and {_namemg}
call custom event "team spawn set" to details {_details::*}
call custom event "spawn set" to details {_details::*}
#Points of a team
get expression number of points of [[the] team] %string% (from|of) [[the] mini[s](-| )game[s]] %string%:
set {_name} to expression-1
set {_namemg} to expression-2
if yaml "%{_namemg}%" is loaded:
set {_points} to skript-yaml value "GameAPI.%{_namemg}%.Teams.Team %{_number}%.Points" from "%{_namemg}%"
continue {_points}
else:
continue false
#Team of player
get expression [[the] team] of %player% from [[the] mini game] %string%:
#delay the current expression
set {_player} to expression-1
set {_namemg} to expression-2
if yaml "%{_namemg}%" is loaded:
set {_listnodes::*} to skript-yaml nodes "GameAPI.%{_namemg}%.Teams" from "%{_namemg}%"
loop {_listnodes::*}:
# wait 1 tick
set {_listplayer::*} to skript-yaml list "GameAPI.%{_namemg}%.Teams.%loop-value%.Players" from "%{_namemg}%"
If {_listplayer::*} contains "%{_player}%":
set {_return} to loop-value
replace all "Team " with "" in {_return}
continue "%{_return}%"
else:
continue false
#Spawn of a team
get expression spawn of [[the] team] %string% from [[the] mini game] %string%:
set {_name} to expression-1
set {_namemg} to expression-2
if yaml "%{_namemg}%" is loaded:
set {_spawn} to skript-yaml value "GameAPI.%{_namemg}%.Teams.Team %{_name}%.Spawn" from "%{_namemg}%"
continue "%{_spawn}%"
else:
continue false
#Spawn of a mini-game
get expression spawn of [[the] mini game] %string%:
set {_namemg} to expression-1
if yaml "%{_namemg}%" is loaded:
set {_spawn} to skript-yaml value "GameAPI.%{_namemg}%.Spawn" from "%{_namemg}%"
continue "%{_spawn}%"
else:
continue false
#Loop player in team
get plural expression all players from team %string% of %string%:
set {_name} to expression-1
set {_namemg} to expression-2
if yaml "%{_namemg}%" is loaded:
set {_listplayers::*} to skript-yaml list "GameAPI.%{_namemg}%.Teams.Team %{_name}%.Players" from "%{_namemg}%"
continue "%{_listplayers::*}%"
else:
continue false
#Loop player in mini-game
get plural expression all players (from|of) [[the] mini[s](-| )game[s]] %string%:
set {_name} to expression-1
set {_namemg} to expression-2
if yaml "%{_namemg}%" is loaded:
set {_listplayers::*} to skript-yaml list "GameAPI.%{_namemg}%.Players" from "%{_namemg}%"
continue "%{_listplayers::*}%"
else:
continue false
#Loop team
get plural expression all team[s] (from|of) [[the] mini[s](-| )game[s]] %string%:
set {_namemg} to expression-1
if yaml "%{_namemg}%" is loaded:
set {_listnodes::*} to yaml nodes "GameAPI.%{_namemg}%.Teams" from "%{_namemg}%"
continue "%{_listnodes::*}%"
else:
continue false
#Loop mini-game
get plural expression all mini[s][-]game[s]:
set {_listmg::*} to directory "plugins/GameAPI/"'s files
continue "%{_listmg::*}%"
on inventory click:
if name of event-inventory is "test":
broadcast "yeah!"
</pre>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" i></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<script>
/**
* Parser Skript
* Permet d'appliquer des classes de coloration syntaxique au code
* Ecris par Uneo7
**/
let code = $('pre').html();
// Chaines entre guillemets
// Remplacement de tous les guillements par lur représentation HTML (evite les conflits plus tard)
code = code.replace(
/"/gim,
'"'
);
// Force les chaines entre guillement à rester grises
code = code.replace(/"(.*)"/gi, match => {
const split = match.split(/"/gi);
split.shift();
split.pop();
if (split.length === 1) {
return `<span class="gray">"${split[0].trim()}"</span>`;
}
match = '';
for (let i in split) {
if (i % 2 === 0) {
match += `<span class="gray">"${split[i].trim()}"</span>`;
continue;
}
match += ' ' + split[i].trim() + ' ';
}
return match;
});
// Fonctions
// Retour
code = code.replace(
/(function.*::\s{0,})(.*):/gim,
'$1<span class="blue">$2</span>:'
);
// Signature
code = code.replace(
/^function\s(\w{1,})(\(.*\))\s{0,}:/gim,
'function <span class="yellow">$1</span><span class="blue">$2</span>:'
);
// Conditions / Boucles
// While if else elseif
code = code.replace(
/(while|if|else|else if)/gi,
'<span class="orange">$1</span>'
);
// Boucles
code = code.replace(/(loop\s(.*)\stimes\s{0,}:)|(loop(.*)\s{0,}:)/gi, (match, p1, p2, p3, p4) => {
if (p1 === undefined && p2 === undefined) {
return `<span class="orange">loop</span><span class="green">${p4}</span>:`
}
if (p3 === undefined && p4 === undefined) {
return `<span class="orange">loop</span><span class="green">${p2}</span><span class="orange">times</span>:`
}
});
// Mot clef
// Tous les events qui ne comment pas par: on, command, function, options, variables
code = code.replace(
/^(?!on|command|function|options|variables|[\s]+)(.*):/gim,
'<span class="yellow">$1</span>:'
);
// Events on
code = code.replace(
/^(on)(.*)(:)/gim,
'$1<span class="yellow">$2</span>$3'
);
// on, command, function, options, variables
code = code.replace(
/^(on|command|function|variables|options)/gim,
'<span class="red">$1</span>'
);
// Modifiers
code = code.replace(
/(\sadd\s|\sgive\s|\sincrease\s|\sset\s|\sremove\s|\ssubstract\s|\sreduce\s|\sdelete\s|\sclear\s|\sreset\s|\sfrom\s|\sof\s|\swith\s|\sin\s|\sfor\s|\sby\s|\sto\s|\sis\s)/gi,
'<span class="dark-blue">$1</span>'
);
// Event-values
code = code.replace(
/event-(\w+)/gim,
'<span class="green">$&</span>'
)
// Pourcentages (expressions as string)
code = code.replace(
/(\%([a-zA-Z0-9_{} ]*)\%)/gim,
'<span class="dark-green">$1</span>'
)
// Variables
// Globale
code = code.replace(
/({(?!_)\w{1,}})/gi,
'<span class="purple">$1</span>'
);
// Locale
code = code.replace(
/({_\w{1,}})/gi,
'<span class="dark-gray">$1</span>'
);
// Option
code = code.replace(
/({@\w{1,}})/gi,
'<span class="cyan">$1</span>'
);
// Comentaires
code = code.replace(/(#.*)/gi, (match, p1, p2) => {
const split = match.split(/</gi);
if(split.length === 1) return `<span class="dark-green">${match}</span>`;
let comment = [];
for(let i in split) {
let elem = split[i].replace(/^span\sclass=".*">/gi, '');
elem = elem.replace(/^\/span>/gi, '');
comment.push(elem.trim());
}
return `<span class="dark-green">${comment.join(' ')}</span>`;
});
$('pre').html(code);
</script>
</body>
</html>