Skip to content

Commit 45951f1

Browse files
KoloInDaCribKade-github
authored andcommitted
add info abt new labels, alt insts and locking songs outta freeplay
1 parent 87094f9 commit 45951f1

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

assets/content/cookbook/Advanced/3.ScriptedSongs.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,76 @@ class BallisticSong extends Song {
2424

2525
You can then add override functions to perform custom behavior.
2626

27+
## Custom 'NEW'-Label criteria
28+
29+
Usually, in the Freeplay menu, a song would not have the glowing 'NEW' label. However if you override the function `isSongNew`, you can have the label appear if a specific criteria is met. An example of this is found in the script for Cocoa[^cocoa] which returns true if the variation is Pico and the player hasn't beaten Cocoa Pico Mix.
30+
```haxe
31+
// ...
32+
33+
// Line 29
34+
public override function isSongNew(currentDifficulty:String, currentVariation:String):Bool
35+
{
36+
if (currentVariation == 'pico') return !Save.instance.hasBeatenSong(this.id, null, 'pico');
37+
38+
return false;
39+
}
40+
41+
// ...
42+
```
43+
44+
## Custom Alternate Instrumental behavior
45+
46+
Instead of reading from the song's metadata file for possible alternate instrumentals, you can use scripts to lock some of them out of being used until a criteria is met. An example of this is found in the script for Stress[^stress] which locks the pico instrumental behind completing the pico remix, as well as not provide the default instrumental if the song is selected on the pico variation.
47+
```haxe
48+
// ...
49+
50+
// Line 42
51+
public override function listAltInstrumentalIds(difficultyId:String, variationId:String):Array<String>
52+
{
53+
if (difficultyId == 'easy' || difficultyId == 'normal' || difficultyId == 'hard')
54+
{
55+
var hasBeatenPicoMix = Save.instance.hasBeatenSong(this.id, null, 'pico');
56+
57+
switch (variationId)
58+
{
59+
case 'pico':
60+
// return hasBeatenPicoMix ? [''] : [];
61+
// No Pico mix on BF instrumental, sorry!
62+
return [];
63+
default:
64+
return hasBeatenPicoMix ? ['pico'] : [];
65+
}
66+
}
67+
68+
return [];
69+
}
70+
71+
// ...
72+
```
73+
74+
## Hiding the Song from the Freeplay Menu
75+
76+
The most important thing to override here is the function `listDifficulties`. If you return an empty array, the song will be omitted from the Freeplay menu. An example to this is in the song 2hot[^2hot]
77+
```haxe
78+
// ...
79+
80+
// Line 51
81+
public function listDifficulties(variationId:String, variationIds:Array<String>, showLocked:Bool):Array<String>
82+
{
83+
if (showLocked || Save.instance.hasBeatenLevel('weekend1'))
84+
{
85+
return super.listDifficulties(variationId, variationIds);
86+
}
87+
88+
// Hide all difficulties if the player has not beaten the week.
89+
return [];
90+
}
91+
92+
// ...
93+
```
94+
95+
[^cocoa]: <https://github.com/FunkinCrew/funkin.assets/blob/main/preload/scripts/songs/cocoa.hxc>
96+
[^2hot]: <https://github.com/FunkinCrew/funkin.assets/blob/main/preload/scripts/songs/2hot.hxc>
97+
[^stress]: <https://github.com/FunkinCrew/funkin.assets/blob/main/preload/scripts/songs/stress.hxc>
98+
2799
> Author: [EliteMasterEric](https://github.com/EliteMasterEric)

0 commit comments

Comments
 (0)