Update 'Building your first mod'

Lucas Schwiderski 2023-03-16 15:30:13 +01:00
parent b3569b7f62
commit 5bc9709393

@ -1,3 +1,18 @@
# Create your first mod
### tl;dr:
1. Open a Command Prompt/terminal (on Windows, I suggest installing [Git for Windows](https://gitforwindows.org/) and running that through [Windows Terminal](https://learn.microsoft.com/en-us/windows/terminal/install))
2. Run `dtmt new <path/to/new/folder>` and fill out the prompts
3. Edit the file `scripts/mods/<id>/init.lua`
4. Run `dtmt build`, which will produce some files in `out/`
5. Run `dtmt package`, which will produce a zip file
6. Import that zip file in DTMM and deploy it
7. Check **Continued Development** below
---
In a Command Prompt/terminal, run `dtmt new <path/to/new/folder>` to create a skeleton structure from the default template. In a Command Prompt/terminal, run `dtmt new <path/to/new/folder>` to create a skeleton structure from the default template.
During this, DTMT will prompt for several fields, including: During this, DTMT will prompt for several fields, including:
@ -24,3 +39,20 @@ DTMT will now create the given directory from the mod template:
You're now ready to start editing the `init.lua` file. For starters, you might want to just add a simple `print("Hello, world!")`, which will print this string in your console logs once you've loaded the mod. You're now ready to start editing the `init.lua` file. For starters, you might want to just add a simple `print("Hello, world!")`, which will print this string in your console logs once you've loaded the mod.
With the file edited, you now need to turn your mod into something that DTMM can load into the game. To do that, navigate to your mod's folder (where the `dtmt.cfg` is) and run in sequence `dtmt build` and `dtmt package`. The first command will compile your mod files into game bundles, the second will package things into a single `<id>.zip` for distribution. Watch the output for any errors, but if all goes well, you can then import your packaged mod in DTMM and deploy. With the file edited, you now need to turn your mod into something that DTMM can load into the game. To do that, navigate to your mod's folder (where the `dtmt.cfg` is) and run in sequence `dtmt build` and `dtmt package`. The first command will compile your mod files into game bundles, the second will package things into a single `<id>.zip` for distribution. Watch the output for any errors, but if all goes well, you can then import your packaged mod in DTMM and deploy.
# Continued development
After you've verified that your new mod has been loaded in the game, you will want to start the actual implementation of your mod. Since it would be rather tedious to create a new zip file, import that in DTMM and deploy it for every change, there is one more command to learn: `dtmt watch --deploy <path/to/Warhammer 40k Darktide>`.
This will make DTMT continuously watch for changes in your mod's files, re-build the mod bundles and immediately deploy them to the given game directory. The path given should be the directory _above_ `bundle/`, e.g. `C:\Program Files\Steam\steamapps\common\Warhammer 40k Darktide`.
But there are two limitations, since DTMT cannot do a full deployment like DTMM:
- The mod has to be deployed once through DTMM first
- It only works as long as the list of files doesn't change. I.e. if you add a new file to your mod, or remove one, you will have to deploy that through DTMM again, once
# Dev tools
### Lua
DTMT will already run a basic syntax check on your Lua files. For additional static analysis, install [luacheck](https://github.com/mpeterv/luacheck) and integrate it with your chosen editor.