@@ -151,8 +151,9 @@ def implement(self):
151151 self .parentFunction .append ("#" + self .text )
152152
153153class Function :
154- def __init__ (self , name , desc ):
154+ def __init__ (self , namespace , name , desc ):
155155 self .name = name
156+ self .namespace = namespace
156157 self .code = []
157158 Comment (desc , self ).implement ()
158159
@@ -169,10 +170,10 @@ def implement(self, filePath):
169170defaultPackInfo = False
170171useSnapshots = False
171172
172- initFunction = Function ("load" , "This function is run when the datapack is loaded." )
173- uninstallFunction = Function ("uninstall" , "Can be called to remove the pack and any trace it was ever installed" )
174- tickFunction = Function ("tick" , "This function is run every tick after this datapack is loaded." )
175- customFunctions = {"test" : Function ("test" , "this is a test." )}
173+ initFunction = Function (packId , "load" , "This function is run when the datapack is loaded." )
174+ uninstallFunction = Function (packId , "uninstall" , "Can be called to remove the pack and any trace it was ever installed" )
175+ tickFunction = Function (packId , "tick" , "This function is run every tick after this datapack is loaded." )
176+ customFunctions = {"test" : Function ("example_pack" , " test" , "this is a test." )}
176177
177178def generateCode (code ):
178179 #TODO: Convert each line of code to an instance of Statement or Variable that can then be converted to datapack form.
@@ -231,12 +232,14 @@ def main():
231232 initFunction .append (f'tellraw @a [{{"text":"The pack "}},{{"text":"\\ "{ packName } \\ " ","color":"green","hoverEvent":{{"action":"show_text","contents":[{{"text":"{ packId } \\ n{ packDesc } "}}]}}}},{{"text":"has been sucessfully (re)loaded."}}]' )
232233 uninstallFunction .append (f'tellraw @a [{{"text":"The pack "}},{{"text":"\\ "{ packName } \\ " ","color":"green","hoverEvent":{{"action":"show_text","contents":[{{"text":"{ packId } \\ n{ packDesc } "}}]}}}},{{"text":"has been sucessfully unloaded."}}]' )
233234
235+ os .makedirs (f".saved/data" , exist_ok = True )
234236 print ("Saving functions for use in tags" )
235237 with open (".saved/data/functions.csv" , "w+" ) as file :
236238 data = ["namespace,name" ,f"{ packId } ,internal/load" , f"{ packId } ,internal/tick" , f"{ packId } ,uninstall" ]
237239 for i in customFunctions :
238- data .append (f"{ packId } ,{ i .name } " )
240+ data .append (f"{ customFunctions [ i ]. namespace } ,{ customFunctions [ i ] .name } " )
239241 file .write ("\n " .join (data ))
242+
240243 print ("Generating tag files" )
241244 tags .start (packName , packId , packDesc )
242245
0 commit comments