diff --git a/Migrating-from-loose-files.md b/Migrating-from-loose-files.md index 74c3d53..68209f7 100644 --- a/Migrating-from-loose-files.md +++ b/Migrating-from-loose-files.md @@ -1,6 +1,13 @@ > **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, as well as how to use DTMT to build the mod bundles. -## Automatically +Migration requires two steps: + +1. Rework the project structure and create necessary files to package files into bundles +2. Adjust certain parts of your code + +## 1. Rework project structure + +### Automatically For most projects, the built-in migration command should be enough to convert a mod to the DTMT project structure: @@ -10,12 +17,12 @@ For most projects, the built-in migration command should be enough to convert a 3. In a Command Prompt (or similar terminal application, e.g. [Windows Terminal](https://learn.microsoft.com/en-us/windows/terminal/install)), execute `dtmt migrate C:\path\to\my_mod.id C:\projects` 4. Navigate to `C:\projects\` and execute `dtmt build` and `dtmt package` -## Manually +### Manually -To migrate Lua files from a loose file structure to something that can be built into mod bundles with DTMT, the following is needed: +If the automated way doesn't work for you, or you want to dig in and see how it's done, you'll need the following: - a `dtmt.cfg` that defines the mod's metadata, entry points and packages -- at least one `.package` file that includes your Lua files +- at least one `.package` file that lists your files to be bundled One way to quickly generate a skeleton would be to use `dtmt new` in a new location as outlined in [Building your first mod](Building-your-first-mod), then move files over from your old location. @@ -52,4 +59,10 @@ A suggested final file structure looks as follows: All additional Lua files can then be dropped into `scripts/mods/DMF` (sub-directories are supported) and can be `require`d in-game with the full path, e.g. `require("scripts/mods/DMF/my_extra_file")`. -Modding veterans from VT2 may recognize this file structure 🙂 \ No newline at end of file +Modding veterans from VT2 may recognize this file structure 🙂 + +## 2. Adjust code + +- All script loading must happen via the regular Lua `require` or `dofile`. Functions like `mod:io_dofile` don't work anymore. + You can default to using `mod:require` and `mod:dofile`, which switch internally to do "the right thing" for either bundled or non-bundled mods. +- `mod:add_require_path()` only works for non-bundled mods. Any scripts in bundled mods are already available via `require` (hence the point above) \ No newline at end of file