Skip to content

01_PROJECT_STRUCTURE

Orel138 edited this page Aug 27, 2024 · 1 revision

1. Project Structure

Understanding the proper project structure is crucial for creating a functional Noita wand mod. This chapter will guide you through the recommended folder structure and explain the purpose of each file.

Recommended Folder Structure

YourWandMod/
├── data/                           - Override game's default files (use cautiously)
├── files/                          - Mod-specific files
│   └── wands/
│       ├── custom_wand.png         - Wand image file
│       ├── custom_wand.xml         - Wand entity definition
│       ├── custom_wand_gfx.xml     - Wand graphics settings
│       └── custom_wand_setup.lua   - Wand properties and behavior script
├── init.lua                        - Mod entry point
└── mod.xml                         - Mod metadata

File Descriptions

data/

This directory is used for overriding the game's default files. Use this folder with caution, as it can affect the base game's behavior.

files/

This directory contains mod-specific files. Using this structure helps avoid naming conflicts between different mods.

files/wands/custom_wand.png

This is the image file that defines the visual appearance of your custom wand in the game. Make sure the dimensions of this image match the settings in your custom_wand_gfx.xml file.

files/wands/custom_wand.xml

This XML file defines the wand as an entity in the game. It includes references to other files and sets up the basic properties of the wand.

files/wands/custom_wand_gfx.xml

This XML file specifies how the wand image should be displayed in the game, including animation details if applicable.

files/wands/custom_wand_setup.lua

This Lua script is responsible for setting up the wand's properties and behavior when it's created in the game.

init.lua

This is the entry point of your mod. It's executed when the mod is loaded and can be used to set up global variables or perform any necessary initialization.

mod.xml

This XML file contains metadata about your mod, such as its name, description, and version. It's used by the game to display information about your mod in the mod menu.

Mod File Structure and Interactions

Understanding how the different files in your wand mod interact is crucial for creating a well-organized and functional custom wand. Here's a diagram representing the structure and interactions between the files:

[mod.xml] --> [init.lua]
                 |
                 v
[custom_wand.xml] <--> [custom_wand_setup.lua]
         |
         |---> [custom_wand_gfx.xml]
         |
         |---> [custom_wand_shot.lua]
         |
         |---> [custom_wand.png]

Legend:

---> : "references" or "uses"

<--> : "interacts with"

Explanation of relationships:

  1. mod.xml: This is the entry point of the mod. It defines the mod's metadata and references init.lua.

  2. init.lua: This is the mod's initialization script. It loads the custom wand into the game, typically by referencing custom_wand.xml.

  3. custom_wand.xml: This is the main entity definition file for the wand. It:

    • References custom_wand_gfx.xml for the wand's graphics
    • Uses custom_wand_setup.lua to initialize the wand's properties
    • May reference custom_wand_shot.lua for custom shooting behaviors
    • Indirectly uses custom_wand.png via custom_wand_gfx.xml
  4. custom_wand_setup.lua: This script configures the wand's properties. It interacts with custom_wand.xml by modifying its components.

  5. custom_wand_gfx.xml: This file defines how the wand's sprite should be displayed. It directly references custom_wand.png.

  6. custom_wand_shot.lua: This optional script defines custom shooting behaviors. It's called by custom_wand.xml when the wand is used.

  7. custom_wand.png: This is the wand's image file, used by custom_wand_gfx.xml.

This diagram shows how all the mod files are interconnected, with custom_wand.xml at the center, acting as the central point that links all other elements of the custom wand mod together.

Understanding these relationships will help you organize your mod files effectively and troubleshoot any issues that may arise during development.

By following this structure, you ensure that your mod is organized and easy to maintain. In the next chapter, we'll dive into defining the properties of your custom wand.