-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
627 lines (586 loc) · 29.7 KB
/
Copy pathmain.py
File metadata and controls
627 lines (586 loc) · 29.7 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
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
import os
import json
import tags
import shutil
import re
import sys
import commands
from tools import *
# import convert
packName = "Generated Data Pack"
packId = "generated_data_pack"
packDesc = "Data pack generated from a Minecraft Programming Language compiler"
packShort = "gdp"
defaultPackInfo = False
useSnapshots = False
preinitFunction = commands.Function(
packId, "internal/preload",
"It is necessary to delay the load function by 1 second so that it may be run on world load correctly.",
0)
initFunction = commands.Function(packId, "internal/load",
"This function is run when the datapack is loaded.", 0)
uninstallFunction = commands.Function(
packId, "uninstall",
"Can be called to remove the pack and any trace it was ever installed", 0)
tickFunction = commands.Function(
packId, "internal/tick",
"This function is run every tick after this datapack is loaded.", 0)
customFunctions = {
"exists":
commands.Function(packId, "exists",
"If you can successfully run this function, the pack exists.", 0)
}
listeners = {}
externalFunctions = []
requiredPacks = []
internalListeners = ["load", "tick", "uninstall", "spawn"]
variables = {}
constantVariables = {}
playerPreference = "both"
def generateCode(code, function, path, file, parentScript):
global listeners
global externalFunctions
global customFunctions
global requiredPacks
global packId
global constantVariables
if function == None:
# Top-level statements: Variables and function declarations
for line in code:
# Listener definition
match = re.match(
r'(priority\=(?P<priority>[+-]?\d+)\s+)?(id="(?P<id>[^\"]+)"\s+)?on\s+(?P<name>[a-z_0-9\.\:]+)',
line)
if match != None:
name = match.group("name").replace(":", "_")
id = match.group("id")
priority = match.group("priority")
if not name in listeners:
listeners[name] = []
version = len(listeners[name]) + 1
function = None
if priority == None:
function = commands.Function(
packId,
f"listeners/{name}/{path}{'/' if path != '' else ''}{'.'.join(file.split('.')[:-1])}/{name.replace('.', '_')}{version}",
f"This function is called for every {name} event with 0 priority",
0)
else:
priority = int(priority)
function = commands.Function(
packId,
f"listeners/{name}/{path}{'/' if path != '' else ''}{'.'.join(file.split('.')[:-1])}/{name.replace('.', '_')}{version}",
f"This function is called for every {name} event with {priority} priority",
priority)
function.listenerId = match.group("name")
function.scoreId = name
if id != None:
function.scoreId = id
statements = words(
";",
groups(
line, [["{", "}"], ['"', '"', True]],
False,
requiredPair=["{", "}"])[0],
[['"', '"', True], ["'", "'", True], ["{", "}"],
["[", "]"]], False, True)
customFunctions[function.name] = function
listeners[name].append(function)
generateCode(statements, function, function.path,
f"{name.replace('.', '_')}-{version}.mcscript",
parentScript)
else:
# Function definition
match = re.match(
r'function\s+(desc="(?P<desc>[^\"]+)"\s+)?(?P<name>[a-z_]+)\(\)',
line)
if match != None:
name = match.group("name")
desc = match.group("desc")
function = None
if desc == None:
function = commands.Function(
packId,
f"{path}{'/' if path != '' else ''}{'.'.join(file.split('.')[:-1])}/{name.replace('.', '_')}",
f"The function defined with the name '{name}' in the file '{path}/{file}'",
0)
else:
function = commands.Function(
packId,
f"{path}{'/' if path != '' else ''}{'.'.join(file.split('.')[:-1])}/{name.replace('.', '_')}",
desc, 0)
statements = words(";",
groups(line, [["{", "}"]], False)[0],
[['"', '"', True], ["'", "'", True],
["{", "}"], ["[", "]"]], False, True)
customFunctions[function.name] = function
generateCode(statements, function, function.path,
function.name, parentScript)
else:
# External function definition
match = re.match(
r'def (?P<namespace>[a-z_]+):(?P<name>[a-z_\/]+)',
line)
if match != None:
externalFunctions.append(
commands.Function(
match.group("namespace"), match.group("name"),
"", 0))
else:
# Variable definition
match = re.match(
r'(?P<modifier>global|entity|constant)\s+(desc="(?P<desc>[^\"]+)"\s+)?(?P<type>(?:entity|int|float|string|bool)(?:\<\d+\>)?(?:\[\])?)\s+(?P<name>[a-zA-Z_][a-zA-Z_0-9]*)(\s*\=\s*(?P<value>.+))?',
line)
if match != None:
modifier = match.group("modifier")
t = match.group("type")
name = match.group("name")
value = match.group("value")
desc = match.group("desc")
print(f'Defining variable "{name}"')
commands.Variable(packId, name, modifier, t, value, desc,
True)
else:
# Required pack definition
match = re.match(
r'require\s+(?P<namespace>[a-z_]+)', line)
if match != None:
requiredPacks.append(match.group("namespace"))
else:
pass
else:
# Lower level satements - Instructions
for line in code:
# Literal command
if line[0] == "/":
commands.LiteralCommand(line, function).implement()
else:
# Comment
match = re.match(r'comment((?P<message>.+))(\)$)', line)
if match != None:
message = groups(
match.group("message"), [['"', '"', True]], False)[0]
commands.Comment(message, function).implement()
else:
# Function call
match = re.match(
r'(?P<function>[a-z_0-9\.]+(:)?[a-z_0-9\.]+)(?<!\.)\(\)',
line)
if match != None:
f = match.group("function")
functionList = f.split(":")
if len(functionList) < 2:
functionList = f.split(".")
if len(functionList) == 1:
commands.CallFunction(
f"{packId}:{parentScript}/{functionList[0]}",
function).implement()
else:
commands.CallFunction(
f"{packId}:{'/'.join(functionList)}",
function).implement()
else:
namespace = functionList[0]
functionList = functionList[1].split(".")
commands.CallFunction(
f"{namespace}:{'/'.join(functionList)}",
function).implement()
else:
# Execute clause
match = re.match(
r'(?P<conditions>((if|unless|store|align|anchored|as|at|facing|positioned|rotated)(.)+?\s*)+?)\s*{(?P<code>(.|\s)*)}',
line)
if match != None:
conditions = []
conditionsWords = words(
" ", match.group("conditions"),
[['"', '"', True], ["'", "'", True],
["(", ")"]], False, True)
for condition in conditionsWords:
if condition == "":
continue
elif condition in [
"if", "unless", "store", "align",
"anchored", "as", "at", "facing",
"positioned", "rotated"
]:
conditions.append(condition)
elif condition[0] == "(" and condition[
-1] == ")":
conditions[-1] += " " + condition[1:-1]
else:
conditions[-1] += " " + condition
statements = words(
";", match.group("code"),
[['"', '"', True], ["'", "'", True],
["(", ")"], ["[", "]"], ["{", "}"]], False,
True)
if len(statements) == 1:
wrapper = commands.ExecuteWrapper(
conditions, [], function)
generateCode(statements, wrapper, path, file,
parentScript)
wrapper.implement()
else:
pass
def main():
global packId
global packDesc
global packName
global useSnapshots
global packDesc
global variables
global playerPreference
global packShort
global requiredPacks
print("Start")
mainCode = []
with open("main.mcscript", "r") as data:
print("found main file")
print("Saving the file as a copy in the datapack")
codeList = noComments(data)
# A list of each separate statement or definition without any new lines or tabs
mainCode = words(";", "".join(codeList),
[['"', '"', True], ["'", "'", True], ["(", ")"],
["[", "]"], ["{", "}"]], False, True)
"""print("main file contents:")
for i in range(0,len(mainCode)):
print(f"\t{i}: {mainCode[i]}")"""
if segment("pack-info: ", 0, mainCode[0]):
info = packId = words(" ", mainCode[0],
[['"', '"', True], ["'", "'", True]], False,
False)[1:]
packName = info[0]
packId = info[1]
packShort = info[2]
packDesc = info[3]
print(f'got pack name "{packName}" with id "{packId}"')
useSnapshots = info[4].lower().capitalize()
if useSnapshots == "True":
print("Snapshots have been enabled. Pack format changed to 7.")
else:
print("No snapshots are in use. Pack format is 6.")
playerPreference = info[5].lower()
defaultPackInfo = False
print("Converting to data pack form")
else:
print(
f'no pack info specified. Default values will be used (name "{packName}" id {packId})'
)
defaultPackInfo = True
if os.path.isdir(f".generated/packs/{packName}"):
print("Cleaning up previous generation files")
while os.path.isdir(f".generated/packs/{packName}"):
shutil.rmtree(f".generated/packs/{packName}")
print("Saving main.mcscript as a copy in the datapack")
os.makedirs(
f".generated/packs/{packName}/source",
exist_ok=True)
shutil.copyfile(
"main.mcscript",
f".generated/packs/{packName}/source/main.mcscript"
)
print("Populating default function statements")
commands.Statement(f"schedule function {packId}:{initFunction.name} 1s replace",
preinitFunction).implement()
commands.Statement(f"scoreboard objectives add {packShort}_temp dummy",
initFunction).implement()
commands.Statement(f"scoreboard objectives remove {packShort}_temp",
uninstallFunction).implement()
commands.Statement(f"scoreboard players set {packId} {packShort}_temp 0",
initFunction).implement()
# This line is only here so that the variable will register itself as visible to the rest of the program.
# Initialization and manipulation are covered by other lines.
commands.Variable(packId, f"{packShort}_temp", "entity", "int", "0",
f"Temporary score for this pack.", False)
if playerPreference == "single":
commands.Statement("", initFunction).implement()
commands.Comment("Ensure the game is run in singleplayer",
initFunction).implement()
commands.Statement(
f"execute as @a run scoreboard players add {packId} {packShort}_temp 1",
initFunction).implement()
commands.Statement(
f'execute if score {packId} {packShort}_temp matches 2.. run tellraw @a [{{"text":"The pack "}},{{"text":"\\"{packName}\\"","color":"green","hoverEvent":{{"action":"show_text","contents":[{{"text":"{packId} - {packShort}\\n{packDesc}"}}]}}}},{{"text":" is only compatible with singleplayer.\\nDisabling the pack to avoid unexpected behavior.\\nUse "}},{{"text":"/datapack enable \\"file/{packName}\\"","color":"green","hoverEvent":{{"action":"show_text","contents":[{{"text":"Click to copy this command to the chat bar."}}]}},"clickEvent":{{"action":"suggest_command","value":"/datapack enable \\"file/{packName}\\""}}}},{{"text":" To reenable."}}]',
initFunction).implement()
commands.Statement(
f'execute if score {packId} {packShort}_temp matches 2.. run datapack disable "file/{packName}"',
initFunction).implement()
commands.Statement(
f'execute store success storage {packId} isCompatible int 1 if score {packId} {packShort}_temp matches ..1',
initFunction).implement()
elif playerPreference == "multi":
commands.Statement("", initFunction).implement()
commands.Comment("Ensure the game is run in multiplayer",
initFunction).implement()
commands.Statement(
f"execute as @a run scoreboard players add {packId} {packShort}_temp 1",
initFunction).implement()
commands.Statement(
f'execute if score {packId} {packShort}_temp matches ..1 run tellraw @a [{{"text":"The pack "}},{{"text":"\\"{packName}\\"","color":"green","hoverEvent":{{"action":"show_text","contents":[{{"text":"{packId} - {packShort}\\n{packDesc}"}}]}}}},{{"text":" is only compatible with multiplayer.\\nDisabling the pack to avoid unexpected behavior.\\nUse "}},{{"text":"/datapack enable \\"file/{packName}\\"","color":"green","hoverEvent":{{"action":"show_text","contents":[{{"text":"Click to copy this command to the chat bar."}}]}},"clickEvent":{{"action":"suggest_command","value":"/datapack enable \\"file/{packName}\\""}}}},{{"text":" To reenable."}}]',
initFunction).implement()
commands.Statement(
f'execute if score {packId} {packShort}_temp matches ..1 run datapack disable "file/{packName}"',
initFunction).implement()
commands.Statement(
f'execute store success storage {packId} isCompatible int 1 if score {packId} {packShort}_temp matches 2..',
initFunction).implement()
# Add a new line to the function
commands.Statement("", initFunction).implement()
if defaultPackInfo:
generateCode(mainCode[1:], None, "", "main.mcscript", "main")
else:
generateCode(mainCode, None, "", "main.mcscript", "main")
print("looking for other files")
for subdir, dirs, files in os.walk(os.getcwd()):
dirs[:] = [
d for d in dirs if not d[0] == "." and not d == "__pycache__"
]
for file in files:
if not file == "main.mcscript":
path = os.path.relpath(os.path.join(subdir, file))
if file.endswith(".mcscript"):
print(f"found file \"{path}\"")
with open(path) as data:
print("Converting to data pack form")
generateCode(
words(";", "".join(noComments(data)),
[['"', '"', True], ["'", "'", True],
["{", "}"]], False, True), None, "/".join(
path.split("/")[:-1]), file,
file.split(".")[:-1])
print("Saving the file as a copy in the datapack")
os.makedirs(
f".generated/packs/{packName}/source/{os.path.relpath(subdir)}",
exist_ok=True)
shutil.copyfile(
path,
f".generated/packs/{packName}/source/{path}"
)
elif not file.endswith(".mctag") and not file.endswith(
".py") and not path == "README.md":
print(f"found file \"{path}\"")
print("copying it to the datapack")
os.makedirs(
f".generated/packs/{packName}/data/{packId}/{os.path.relpath(subdir)}",
exist_ok=True)
shutil.copyfile(
path,
f".generated/packs/{packName}/data/{packId}/{path}"
)
print("Saving the file as a copy in the datapack")
os.makedirs(
f".generated/packs/{packName}/source/{os.path.relpath(subdir)}",
exist_ok=True)
shutil.copyfile(
path,
f".generated/packs/{packName}/source/{path}"
)
print("Requiring packs")
if len(requiredPacks) > 0:
commands.Comment("Ensure all required packs are installed.",
initFunction).implement()
for pack in requiredPacks:
commands.Statement(
f"execute if data storage {packId} {{isCompatible:1}} store success score {packId} {packShort}_temp run function {pack}:exists",
initFunction).implement()
commands.Statement(
f'execute if score {packId} {packShort}_temp matches 0 run tellraw @a {{"text":"The required pack \"{pack}\" was not detected to exist.\\n Disabling to avoid unexpected behavior.","color":"red"}}',
initFunction).implement()
commands.Statement(
f'execute if score {packId} {packShort}_temp matches 0 run datapack disable "file/{packName}"',
initFunction).implement()
commands.Statement(
f'execute store success storage {packId} isCompatible int 1 if score {packId} {packShort}_temp matches 1',
initFunction).implement()
commands.Statement("", initFunction).implement()
print("Setting up listener calls")
for key in listeners:
if not key in internalListeners:
scoresToReset = []
listeners[key].sort(key=lambda x: x.priority)
for function in listeners[key]:
if not function.scoreId in variables:
commands.Comment(f"Used for listener {function.listenerId}",
initFunction).implement()
commands.Statement(
f'scoreboard objectives add {function.scoreId[:min([len(function.scoreId), 16])]} {function.listenerId}',
initFunction).implement()
# This line is only here so that the variable will register itself as visible to the rest of the program.
# Initialization and manipulation are covered by other lines.
commands.Variable(packId, function.scoreId, "entity", "int", "0",
f"Used for listener {function.listenerId}", False)
commands.Statement("", tickFunction).implement()
commands.Comment("Run listeners", tickFunction).implement()
commands.Statement(
f'execute as @e[scores={{{function.scoreId[:min([len(function.scoreId), 16])]}=1..}}] at @s run function {function.namespace}:{function.name}',
tickFunction).implement()
scoresToReset.append(
function.scoreId[:min([len(function.scoreId), 16])])
if len(scoresToReset) > 0:
commands.Statement("", tickFunction).implement()
commands.Comment("Reset listener scores", tickFunction).implement()
for score in scoresToReset:
# Reset the score
commands.Statement(f"scoreboard players set @e {score} 0",
tickFunction).implement()
# Remove the score on uninstall
commands.Statement(f"scoreboard objectives remove {score}",
uninstallFunction).implement()
if "tick" in listeners:
# Add a new line to the function
commands.Statement("", tickFunction).implement()
commands.Comment("Run tick listeners", tickFunction).implement()
listeners["tick"].sort(key=lambda x: x.priority)
for function in listeners["tick"]:
commands.Statement(f"function {function.namespace}:{function.name}",
tickFunction).implement()
if "load" in listeners:
# Add a new line to the function
commands.Statement("", initFunction).implement()
commands.Comment("Run listeners", initFunction).implement()
listeners["load"].sort(key=lambda x: x.priority)
for function in listeners["load"]:
commands.Statement(f"function {function.namespace}:{function.name}",
initFunction).implement()
if "uninstall" in listeners:
# Add a new line to the function
commands.Statement("", uninstallFunction).implement()
commands.Comment("Run listeners", uninstallFunction).implement()
listeners["uninstall"].sort(key=lambda x: x.priority)
for function in listeners["uninstall"]:
commands.Statement(f"function {function.namespace}:{function.name}",
uninstallFunction).implement()
if "spawn" in listeners:
# Add a new line to the function
commands.Statement("", tickFunction).implement()
commands.Comment("Run spawn listeners", tickFunction).implement()
listeners["spawn"].sort(key=lambda x: x.priority)
for function in listeners["spawn"]:
commands.Statement(
f"execute as @e[tag=!{packId}_spawned] at @s run function {function.namespace}:{function.name}",
tickFunction).implement()
# The "spawned" tag will be used by some other parts of the generator.
commands.Statement(f"tag @e[tag=!{packId}_spawned] add {packId}_spawned",
tickFunction).implement()
print('Adding "datapack loaded/unloaded" notification')
# Add a new line to the function
commands.Statement("", initFunction).implement()
commands.Comment("Uninstall if incompatible", initFunction).implement()
initFunction.append(
f'execute if data storage {packId} {{isCompatible:1}} run tellraw @a [{{"text":"The pack "}},{{"text":"\\"{packName}\\" ","color":"green","hoverEvent":{{"action":"show_text","contents":[{{"text":"{packId} - {packShort}\\n{packDesc}"}}]}}}},{{"text":"has been sucessfully (re)loaded."}}]'
)
commands.Comment("Uninstall the pack if it is incompatible",
initFunction).implement()
commands.Statement(
f"execute if data storage {packId} {{isCompatible:0}} run function {packId}:{uninstallFunction.name}",
initFunction).implement()
# Add a new line to the function
commands.Statement("", uninstallFunction).implement()
uninstallFunction.append(
f'tellraw @a [{{"text":"The pack "}},{{"text":"\\"{packName}\\" ","color":"green","hoverEvent":{{"action":"show_text","contents":[{{"text":"{packId} - {packShort}\\n{packDesc}"}}]}}}},{{"text":"has been sucessfully unloaded."}}]'
)
commands.Statement(f'datapack disable "file/{packName}"',
uninstallFunction).implement()
commands.Statement("", initFunction).implement()
commands.Comment("Start the tick function", initFunction).implement()
commands.Statement(
f"execute if score {packId} {packShort}_temp matches 1 run function {packId}:{tickFunction.name}",
initFunction).implement()
commands.Statement("", tickFunction).implement()
commands.Comment("Start the tick function again next tick",
tickFunction).implement()
commands.Statement(f"schedule function {packId}:{tickFunction.name} 1t replace",
tickFunction).implement()
os.makedirs(f".saved/data", exist_ok=True)
print("Saving functions for use in tags")
with open(".saved/data/functions.csv", "w+") as file:
data = [
"namespace,name", f"{packId},internal/load",
f"{packId},internal/preload", f"{packId},internal/tick",
f"{packId},uninstall"
]
for i in customFunctions:
customFunctions[i].namespace = packId
print(
f"commands.Function \"{customFunctions[i].namespace}:{customFunctions[i].name}\" is defined. Adding it to the data."
)
data.append(
f"{customFunctions[i].namespace},{customFunctions[i].name}")
for i in externalFunctions:
print(
f'External function "{i.namespace}:{i.name}" is defined. Adding it to the data.'
)
data.append(f"{i.namespace},{i.name}")
file.write("\n".join(data))
print("Generating tag files")
tags.start(packName, packId, packDesc, useSnapshots)
print("setting up data pack files")
os.makedirs(
f".generated/packs/{packName}/data/minecraft/tags/functions",
exist_ok=True)
os.makedirs(
f'.generated/packs/{packName}/data/{packId}/functions/internal',
exist_ok=True)
os.makedirs(
f'.generated/packs/{packName}/data/{packId}/tags/blocks',
exist_ok=True)
os.makedirs(
f'.generated/packs/{packName}/data/{packId}/tags/entity_types',
exist_ok=True)
os.makedirs(
f'.generated/packs/{packName}/data/{packId}/tags/fluids',
exist_ok=True)
os.makedirs(
f'.generated/packs/{packName}/data/{packId}/tags/functions',
exist_ok=True)
os.makedirs(
f'.generated/packs/{packName}/data/{packId}/tags/items', exist_ok=True)
with open(f".generated/packs/{packName}/pack.mcmeta", "w+") as file:
json.dump({
"pack": {
"pack_format": 7 if useSnapshots else 6,
"description": packDesc
}
},
file,
indent=4)
with open(
f".generated/packs/{packName}/data/minecraft/tags/functions/load.json",
"w+") as file:
json.dump({
"replace": False,
"values": [f"{packId}:{preinitFunction.name}"]
},
file,
indent=4)
print("Writing preinit function to data pack")
preinitFunction.implement(
f".generated/packs/{packName}/data/{packId}/functions/{preinitFunction.name}.mcfunction"
)
print("Writing init function to data pack")
initFunction.implement(
f".generated/packs/{packName}/data/{packId}/functions/{initFunction.name}.mcfunction"
)
print("Writing uninstall function to data pack")
uninstallFunction.implement(
f".generated/packs/{packName}/data/{packId}/functions/{uninstallFunction.name}.mcfunction"
)
print("Writing tick function to data pack")
tickFunction.implement(
f".generated/packs/{packName}/data/{packId}/functions/{tickFunction.name}.mcfunction"
)
for name in customFunctions:
print(f'Writing "{name}" function to data pack')
os.makedirs(
f".generated/packs/{packName}/data/{packId}/functions/{customFunctions[name].path}",
exist_ok=True)
customFunctions[name].implement(
f".generated/packs/{packName}/data/{packId}/functions/{name}.mcfunction"
)
print("Done")
if __name__ == "__main__":
main()
# tags.start()
# convert.start()
# regex_test.start()