Skip to content

Commit 3b2b1b4

Browse files
Documentation on using a JSON patch to add a variation.
1 parent 09dd415 commit 3b2b1b4

File tree

2 files changed

+80
-2
lines changed

2 files changed

+80
-2
lines changed
Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,81 @@
11
# Adding Variations to Existing Songs
22

3-
## TODO: Write this part.
3+
Through modding, it is possible to add new variations to existing songs. This is great for adding a new difficulty or remix to an existing song (even if that song is from another mod).
4+
5+
## Obtaining Required Files
6+
7+
The first step is to compose a new remix for the song. If you're making a playable character remix, the composer will have to manually make sure the original vocals line up if you want the option to use alternate instrumentals.
8+
9+
You then have to chart this remix. When you're done, you should have an `Inst.ogg` file, two `Voices` OGG files, a `metadata.json` and a `chart.json`.
10+
11+
## Placing the Files
12+
13+
Next, place the assets in the correct spots in our mod folder! Rename each of the files, adding a variation ID of your choice to the end (so if you're making an erect remixes, rename `Inst.ogg` to `Inst-erect.ogg`):
14+
15+
```
16+
-mods
17+
|-myMod
18+
|-data
19+
|-songs
20+
|-mychart
21+
|-mychart-metadata-erect.json
22+
|-mychart-chart-erect.json
23+
|-songs
24+
|-mychart
25+
|-Inst-erect.ogg
26+
|-Voices-bf-erect.ogg
27+
|-Voices-pico-erect.ogg
28+
|-_polymod_metadata.json
29+
```
30+
31+
## Registering the Variation in the JSON Data
32+
33+
Each chart includes a `songVariations` array, which lets the game know which variations the song has available so it can query their respective metadata files. In order to get the game to load your custom variation, you need to modify the `metadata.json` file for the song's chart, so the game knows that variation exists.
34+
35+
### If the song is from your own mod
36+
37+
If the base song you're adding the remix to is from your own mod, you can just add the variation to the `metadata.json` for your chart.
38+
39+
Add your variation ID to the `playData.songVariations` array (creating the key if it doesn't exist).
40+
41+
```json
42+
{
43+
"playData": {
44+
"songVariations": ["erect"] // Add your new variation to this array.
45+
// ...
46+
}
47+
// ...
48+
}
49+
```
50+
51+
### If the song is from the base game, or a different mod
52+
53+
If the base song you're adding to is from a different mod, you don't want to replace the underlying data in case it changes. You want to instead apply a JSON Patch to the file (which Polymod provides the ability to do).
54+
55+
Create a `_merge` folder in your mod folder, then create a file within that directory whose path matches the one you want to patch, like so:
56+
57+
```
58+
-mods
59+
|-myMod
60+
|-_merge
61+
|-data
62+
|-songs
63+
|-mychart
64+
|-mychart-metadata.json
65+
```
66+
67+
Then we apply a simple patch, which adds a new value to the `playData.songVariations` array. Edit the JSON file and add these contents:
68+
69+
```json
70+
{
71+
{ "op": "add", "path": "/playData/songVariations/-", "value": "erect" }, // Add a new value erect to the end of the songVariations array.
72+
}
73+
```
74+
75+
The patching system is very flexible; it works on any JSON file (base game or provided by another mod) and has support for advanced behavior. See [Merging Files](10-appending-and-merging-files/10-02-merging-files.md) for more information.
76+
77+
## Conclusion
78+
79+
Now, when you start the game, your additional variation should be available in-game!
80+
81+
If you created a character remix, make sure the player character for the remix is included in the `ownedCharacters` data for your custom playable character. See [Custom Playable Characters](05-custom-playable-characters/05-00-custom-playable-characters.md) for more info.

src/10-appending-and-merging-files/10-02-merging-files.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ As soon as it finds the first match, it stops and merges the payload with the sp
7676

7777
### Merging into JSON Files
7878

79-
Merging into JSON files is done using a [JSON Patch](https://jsonpatch.com/) document.
79+
Merging into JSON files is done using a [JSON Patch](https://jsonpatch.com/) document. (NOTE: This significantly differs from JSON patch files created for v0.4.1 and earlier, which used a different system that honestly kinda sucked).
8080

8181
Say we have a JSON data file `data/songs/mysong-metadata.json` like below:
8282

0 commit comments

Comments
 (0)