Skip to content

Commit

Permalink
setup mdbook stuff and format it to mdbook
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjamuffin99 committed Jul 31, 2024
1 parent 96aafd3 commit e879c1c
Show file tree
Hide file tree
Showing 27 changed files with 494 additions and 378 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
book
116 changes: 0 additions & 116 deletions 01 - Fundamentals.md

This file was deleted.

151 changes: 0 additions & 151 deletions 02 - Custom Songs and Custom Levels.md

This file was deleted.

6 changes: 6 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[book]
authors = ["The Funkin' Crew Inc.", "EliteMasterEric"]
language = "en"
multilingual = false
src = "src"
title = "Friday Night Funkin' Modding Documentation"
5 changes: 5 additions & 0 deletions src/01-fundamentals/01-00-fundamentals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Creating a Friday Night Funkin' Mod - Fundamentals

This guide will walk you through the process of creating a functioning, fully compatible Friday Night Funkin' mod, using the game's official systems for loading custom content and scripts. Once your mod is complete, you will be able to place it in the `mods` folder in your game install and use its content in-game without overriding the base game content and still maintain compatibility with other mods.

This chapter in particular goes through a lot of core concepts of modding in Funkin' that will get used in other guides, so be sure to read through it carefully.
51 changes: 51 additions & 0 deletions src/01-fundamentals/01-01-the-metadata-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# The Metadata File

To start, create a new folder within your `mods` folder. This is where your mod's assets and scripts will live. Next, create a new text file, and change its name to `_polymod_meta.json`. Make sure you didn't accidentally name it `_polymod_meta.json.txt`!

Inside this file, we will put the information the game needs in order to learn about your mod. I recommend doing this with a program like [Visual Studio Code](https://code.visualstudio.com/), it will correct you if you accidentally misplace a comma or something.

```json
{
"title": "Intro Mod",
"description": "An introductory mod.",
"contributors": [
{
"name": "EliteMasterEric"
}
],
"dependencies": {
"modA": "1.0.0"
},
"optionalDependencies": {
"modB": "1.3.2"
},
"api_version": "0.1.0",
"mod_version": "1.0.0",
"license": "Apache-2.0"
}
```

`_polymod_meta.json` has the following fields:

- `title`: A readable name for the mod.
- `description`: A readable description for the mod.
- `contributors`: A list of Contributor objects.
- `homepage`: A URL where users can learn more about your mod.
- `dependencies`: A map of mod IDs which are mandatory dependencies, along with their version numbers.
- These are the mods which must also be loaded in order for this mod to load.
- If the mod is not included, it will fail.
- The mod list will be reordered such that dependencies load first.
- `optionalDependencies`: A map of mod IDs which are optional dependencies, along with their version numbers.
- These mods do not necessarily need to be installed for this mod to load, but they will still force the mod list to be reordered so that the dependencies load before this mod.
- `api_version`: A version number used to determine if mods are compatible with your copy of Funkin'. Leave this as `0.1.0`.
- `mod_version`: A version number specifically for your mod. Choose any version or leave it at `1.0.0`.
- `license`: The license your mod is distributed under. [Pick one from here](https://opensource.org/licenses) or just leave it as `Apache-2.0`.

A Contributor has the following fields:

- `name`: The contributor's name.
- `role`: *(optional)* The role the contributor played, for example "Artist" or "Programmer"
- `email`: *(optional)* A contact email
- `url`: *(optional)* A homepage URL

Many of these fields are intended to be used in the future by an upcoming Mod Menu interface, which will allow users to organize their mods.
15 changes: 15 additions & 0 deletions src/01-fundamentals/01-02-loading-the-mod-in-game.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Loading the Mod In-Game

Now that you have a metadata file, you can start the game! Pro tip, if you run the game from the command line, you can see lots of useful debug messages, like these messages that indicate your mod has loaded!

```shell
source/funkin/modding/PolymodHandler.hx:316: Found 5 mods when scanning.
source/funkin/modding/PolymodHandler.hx:118: Attempting to load 5 mods...
...
source/funkin/modding/PolymodErrorHandler.hx:79: [INFO-] LOADING MOD - Preparing to load mod ../../../../example_mods/introMod
source/funkin/modding/PolymodErrorHandler.hx:79: [INFO-] LOADING MOD - Done loading mod ../../../../example_mods/introMod
...
source/funkin/modding/PolymodHandler.hx:169: Mod loading complete. We loaded 5 / 5 mods.
```

Neat! But right now, your mod doesn't do anything.
32 changes: 32 additions & 0 deletions src/01-fundamentals/01-03-asset-replacement-and-additions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Asset Replacement and Additons

## Asset Replacement

The key thing that Polymod allows you to do is to replace assets. This is done by adding those files to your mods folder in the same location as they would go.

For example, you can replace Girlfriend's sprites by placing your new sprites in the same location as they are in the `assets` folder, which would be `shared/images/characters/GF_assets.png`.

In other words, structure your mod like so:

```
-assets
-manifest
-plugins
-mods
|-myMod
|-shared
|-images
|-characters
|-GF_assets.png
|-GF_assets.xml
|-_polymod_metadata.json
-Funkin.exe
```

When the game goes to load a character's sprites, it will make a request internally to retrieve the `assets/shared/images/characters/GF_assets.png` file to use for the texture (and the corresponding `XML` to split the image into individual frames). When it does, Polymod intercepts that request and checks if there is a file of that name among the loaded mods, and if so, it will use that instead.

## Asset Additions

Polymod also allows you to add new files to the game. This is notable, as trying to place new files into the `assets` directory doesn't work, the game won't recognize those files.

The game still needs to get told to load those assets for them to get used, but there are many functions which load all the files in a given folder (such as the Song Registry, the Character Registry, the Stage Registry, etc). We'll look more into those later.
7 changes: 7 additions & 0 deletions src/01-fundamentals/01-04-mod-load-order.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Mod Load Order

You may wonder what happens in the case where multiple mods provide a given file.

The answer is simple; mod order matters. If you have two mods installed which replace a particular asset, the mod which loads last will get precedence over mods that get loaded earlier, similar to Minecraft's resource pack system. This is evaluated on a per-file basis, so if Mod A replaces Pico and GF and Mod B replaces only GF, and Mod B is loaded after Mod A, you'll see the Pico from Mod A and the Girlfriend from Mod B.

In the current version of Friday Night Funkin', there is no accessible means of altering mod load order. Mods will load in alphabetical order by default, with dependencies being loaded first.
Loading

0 comments on commit e879c1c

Please sign in to comment.