How to make a module - mariusz-tang/KTaNE-Module-Template GitHub Wiki

This guide is aimed at complete beginners to making modded modules for Keep Talking and Nobody Explodes. It does not assume knowledge of C# and how to use Unity, although it helps immensely to have some programming experience — this is not a coding tutorial.

Setup

There are several things you will need to get started making mods. The most important of these are Unity and a code editor such as Visual Studio or Visual Studio Code. It's also recommended to have a Version Control System; most people use Git with GitHub for hosting.

Unity

Unity is the game engine upon which the game was built. We also use it to make mods for the game.

The version of Unity you will need is Unity 2017.4.22, which you can download here.

You may be asked to select which modules you would like to install with Unity. I recommend picking Standard Assets only; you should not need any of the other modules, and you can install them at a later time should you need them.

Code Editor

A code editor is used to, unsurprisingly, edit code. Technically, you could use any text editor for this task, but many modern code editors and IDEs provide useful features like syntax highlighting and IntelliSense, so it's recommended that you use one.

I personally use Visual Studio Code as my code editor, although this is harder to set up to use with Unity for making mods. If you are just starting out, I recommend using Visual Studio. You can download both here (for Visual Studio, pick Community 2022).

Version Control

A version control system is software that is used to keep track of changes you make to your project over time, and allows you to roll back your code to a past version in case you mess anything up.

In order to follow along with this guide using the template, you should use Git with GitHub. I recommend GitHub Desktop, which allows you to interact with GitHub using a GUI instead of the command line or a web browser.

You can get GitHub Desktop here. It should prompt you to make a GitHub account (or sign in), and to install Git if you haven't already.

Downloading the template

NOTE: THIS IS CURRENTLY OUTDATED SINCE THIS IS NOW A PLUGIN. UPDATE SOON.

Once you have GitHub Desktop installed and set up, you are ready to download a copy of the template. To do so, click on Use this template > Create a new repository at the top of the GitHub page for this repository (you should already be on this page).

create-new-repository

In the menu that opens, give your repository a suitable name, and optionally a description.

Here, you may also choose to make your repository private, however I recommend you keep it public as this allows other modders to view your code and help resolve issues, or even take inspiration from it!

If you wish to download the example modules (more on these at the end) in addition to the template, then check the Include all branches box. Otherwise, leave it unchecked.

Finally, click Create repository from template.

set-up-template

Next, open GitHub Desktop. In the top left, click File > Clone Repository.

clone-repository

Select your new repository, pick a suitable directory to store the repository in (I recommend making one just for KTaNE modules!), and hit Clone.

clone-repository-menu

You may wish to delete or edit the README.md file and ModGuide directory from your copy of the template.

Now you are ready to start modding!

Exploring the template

Setting up the scene

Open the project in Unity (when Unity asks you for a "project", you should select the entire repository folder).

In the Project tab, rename the _Module folder to match the name of your module. Then, open the folder, and rename the Module.unity (scene) and Module.prefab files to match the name of your module. Finally, drag the scene file into the Hierarchy tab, and delete the existing Untitled scene.

In the Hierarchy tab you should now see a Main Camera, Directional Light, TestHarness, and your module.

set-up-scene

To view the module, double-click it in the Hierarchy, then click the small white cube in the top-right corner to set the view to Isometric mode, and click the green Y-axis indicator to view the module head-on.

zoom-and-perspective

Now, if you click the play button at the top of the screen, a test bomb will start up with the currently empty module on it. Click the play button again to stop the session.

Select your module by clicking on it in the Hierarchy, and its information will show up in the Inspector tab on the right. Here, you should set the Module Type and Module Display Name fields, and check the Requires Timer Visibility box if relevant for your module.

The Module Type is also known as the "module ID", and is what is needed by DMG to load the module. I recommend that it consists of alphanumeric characters only.

The Module Display Name is the name that will be displayed on the Repository of Manual Pages.

module-properties-in-inspector

Scripts

In Unity, at the top-left of the screen, click Edit > Preferences..., then click on External Tools, and set your External Script Editor to your preferred code editor. Close the menu.

Then, right-click in the Project tab and select Open C# Project. Navigate to Assets > _<ModuleName> > _Scripts, and open ModuleModule.cs (in Visual Studio, you should just be able to open ModuleModule.cs directly).

This file contains comments about how to use it. I go over these in more detail in the example module guides (WIP). For now, rename the file and class to match the name of your module (these names must match or Unity will not recognise the script as a component).

Now, back in Unity, open the _Scripts folder and select your module in the Hierarchy and drag the script into the now missing component slot in the Inspector.

fix-missing-script-issue

You should now be ready to customise your mod and implement behaviours. For more help with this, see the example module guides (WIP).

Extra files

This template contains some extra files that have not yet been mentioned:

  • In the _Scripts folder there is a file named ModuleButton.cs, which I use for a basic animated button. The Animations folder contains an Animator Controller template to use with this script.
  • The Materials folder contains a material called ComponentPuzzleBackgroundGreyScale.mat, and a corresponding texture is found in the Textures folder. These are used for changing the background colour of the module while getting rid of the blue tint from the original background.
  • There is also a Preview Image.png file which is used when uploading the module to Steam (although you should provide an image of your module, not a blank one).

Uploading your module to Steam

In Unity, at the top of the screen, click Keep Talking ModKit > Configure Mod, then fill out the information in ModConfig. Add a preview image if you haven't already.

configure-mod

Drag your module from the Hierarchy into the prefab file in the Project tab to update the prefab.

update-prefab

Click on the prefab. You should see that it is has the mod.bundle tag. If not, click on None, and set it (you may need to first create it by clicking New...).

mod-dot-bundle

If you would like to include the manual with the module, place a PDF version of it <RepoName>\Manual\pdfs\Modules\.

Next, build the module by clicking Keep Talking ModKit > Build AssetBundle.

Finally go to Keep Talking ModKit > Steam Workshop Tool (start Steam if needed). Select the relevant module type, provide some Change Notes (something like "Initial upload" is fine), and hit Create New Workshop Item and Publish to Steam.

If the publish button is still greyed-out after entering Change Notes and selecting the module type, simply close the Workshop Tool, and repeat the steps. It's buggy for some reason </3.

steam-workshop-tool

Finally, navigate to the Steam Workshop Item page by going to Steam, then clicking <Your Name> > Content > Workshop Items. At the bottom on the right, set the visibility of the item to Public.

set-visibility-public

Manual

Remember to post your manual (and JSON) in the #repo-requests channel of the Official KTaNE Discord Server so that it can be uploaded to the Repository of Manual Pages. For more help with this, ask around in the #repo-discussion channel.

Note: Your module should be uploaded to Steam before the manual can be uploaded.

I cover making a manual in the Regular Module Example Guide (WIP).

If you found this guide helpful or have questions or the like, I would greatly appreciate your feedback! You can contact me at ku.ro on Discord.

⚠️ **GitHub.com Fallback** ⚠️