You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: assets/content/cookbook/Advanced/3.ScriptedSongs.md
+32-16Lines changed: 32 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,16 +24,37 @@ class BallisticSong extends Song {
24
24
25
25
You can then add override functions to perform custom behavior.
26
26
27
+
## Variation-Specific Song Scripts
28
+
29
+
As of 0.7.4, if in the constructor you were to add an anonymous structure with the field `variation` as a parameter next to the song id, the song script will only be active for that variation. This prevents many conflicts with base game scripts and other mods that may add a variation, as the game would only call the functions from the variation-specific script. If a song doesn't have a variation-specific script, it will fallback to the default one, if it exists. An example of a variation-specific script can be found for Darnell Erect[^darnell]
30
+
```haxe
31
+
import funkin.play.song.Song;
32
+
import funkin.save.Save;
33
+
34
+
class DarnellErectSong extends Song
35
+
{
36
+
public function new()
37
+
{
38
+
super('darnell',
39
+
{
40
+
variation: 'erect'
41
+
});
42
+
}
43
+
44
+
// ...
45
+
}
46
+
```
47
+
27
48
## Custom 'NEW'-Label criteria
28
49
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.
50
+
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 (Pico Mix)[^cocoa] which returns true if the variation is Pico and the player hasn't beaten Cocoa Pico Mix.
30
51
```haxe
31
52
// ...
32
53
33
-
// Line 29
54
+
// Line 14
34
55
public override function isSongNew(currentDifficulty:String, currentVariation:String):Bool
35
56
{
36
-
if (currentVariation == 'pico') return !Save.instance.hasBeatenSong(this.id, null, 'pico');
57
+
if (currentVariation == 'pico') return !Save.instance.hasBeatenSong(this.id, null, this.variation);
37
58
38
59
return false;
39
60
}
@@ -47,25 +68,19 @@ Instead of reading from the song's metadata file for possible alternate instrume
47
68
```haxe
48
69
// ...
49
70
50
-
// Line 42
71
+
// Line 21
51
72
public override function listAltInstrumentalIds(difficultyId:String, variationId:String):Array<String>
52
73
{
74
+
var results:Array<String> = super.listAltInstrumentalIds(difficultyId, variationId);
0 commit comments