diff --git a/Migrating-from-loose-files.md b/Migrating-from-loose-files.md new file mode 100644 index 0000000..56992b2 --- /dev/null +++ b/Migrating-from-loose-files.md @@ -0,0 +1,62 @@ +> **NOTE**: If this is your first time migrating a mod, I strongly suggest going through [Building your first mod](Building-your-first-mod) once, to play around with and get a feel for the new file structure. + +To migrate Lua files from a loose file structure to something that can be built into mod bundles with DTMT, the following is needed: + +- a `dtmt.cfg` that defines the mod's metadata, entry points and packages +- at least one `.package` file that includes your Lua files + +Use the following template to create your `dtmt.cfg`: + +```sjson +// The ID string you pass to `get_mod()` +id = "" +// The human-readable name of the mod. This will show up in places like DTMM's mod list and DMF's options view +name = "" +// A summary of what your mod does. Shows up in DTMM +description = "" +// A version number to track changes in your mod with. Not used, yet, but good practice to always have anyways. +version = "" + +// The Lua files passed in the second parameter of DMF's `new_mod` +resources = { + // The Lua file to be called by DMF when it initializes your mod. + init = "" + data = "" + localization = "" +} + +packages = [ + // At least one package file to load your files. It doesn't have to be named after your mod's ID value, but it is good practice to do so. + "packages/" +] +``` + +Please note that all file paths should be specified _without_ file extension. The `resources` section can be adapted from the contents of your `.mod` file. All instances of `` are intended to be replaced with the value you specify in `id = ""`, i.e. the value passed to DMF's `new_mod` and `get_mod`. + +The `.package` file supports wildcards, so the most simple version would look like this: + +```sjson +lua = [ + "scripts/mods//*" +] +``` + +A suggested final file structure looks as follows: + +```none + +└── + ├──dtmt.cfg + ├──packages + │ └──.package + └──scripts + └──mods + └── + ├──data.lua + ├──init.lua + └──localization.lua +``` + +All additional Lua files can then be dropped into `scripts/mods/` (sub-directories are supported) and can be `require`d in-game with the full path, e.g. `require("scripts/mods//my_extra_file")`. + +Modding veterans from VT2 may recognize this file structure 🙂 \ No newline at end of file