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
+72Lines changed: 72 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,4 +24,76 @@ class BallisticSong extends Song {
24
24
25
25
You can then add override functions to perform custom behavior.
26
26
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>
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'))
0 commit comments