Documentation - The-Iceburg/TotemsPlus GitHub Wiki

def DOC(worldLocation, nameList, weightList, inGameName, inGameLore, loreList):

When we define the 'DOC' function we take 6 parameters:

  • worldLocation
    • The exact location of the world which the user is creating the datapack for.
    • We need this in order to be able to create the documentation.txt file inside the datapck
  • nameList
    • The list of names the user has entered for each totem.
    • We need this to generate the give commands, drop chance and totem list
  • weightList
    • The list of weights the user has entered for each totem
    • We need this to help calculate the drop chances for each totem
  • inGameName
    • This is a list of Booleans to see if the user wants for the name they have entered for each totem to be displayed in-game
    • We need this when generating the give commands to know if we should add the name tag
  • inGameLore
    • This is a list of Booleans to see if the user wants for the lore they have entered for each totem to be displayed in-game
    • We need this when generating the give commands to know if we should add the lore tag
  • loreList
    • The list of lore the user has entered for each totem.
    • We need this to generate the give commands so we have values to add for the lore tags

doc = open(worldLocation + "/datapacks/Totems+ CMD/documentation.txt", 'w+')

First we open/create the documentation file in the appropriate place with use of the worldLocation parameter. We set this to the doc variable for use later in the function. We also open in the 'w+' mode as this not only allows us to create the file but also edit/write to it.

doc.write('Totems+ Custom Datapack Documentation\n')

doc.write('\n')

Next we write the general information to the file. This isn't indented as it is not dependent on any of our taken parameters. In short every documentation file will have this information written to it.

doc.write('List of Totems:\n')

Now we write the heading for our first piece of information the list of totems and their custom model data codes