class Song
package funkin.play.song
implements IRegistryEntry<SongMetadata>, IPlayStateScriptedClass
extended by ScriptedSong
Available on all platforms
This is a data structure managing information about the current song.
This structure is created when the game starts, and includes all the data
from the metadata.json file.
It also includes the chart data, but only when this is the currently loaded song.
It also receives script events; scripted classes which extend this class can be used to perform custom gameplay behaviors only on specific songs.
Static variables
staticfinalread onlyDEFAULT_STAGE:String = "mainStage"
The default value for the song's playable stage.
staticfinalread onlyDEFAULT_TIMEFORMAT:SongTimeFormat = SongTimeFormat.MILLISECONDS
The default value for the song's time format
Static methods
staticbuildRaw(songId:String, metadata:Array<SongMetadata>, variation:String, charts:Map<String, SongChartData>, includeScript:Bool = true, validScore:Bool = false):Song
Build a song from existing metadata rather than loading it from the assets folder.
Used by the Chart Editor.
Parameters:
songId | The ID of the song. |
|---|---|
metadata | The metadata of the song. |
variations | The list of variations this song has. |
charts | The chart data for each variation. |
includeScript | Whether to initialize the scripted class tied to the song, if it exists. |
validScore | Whether the song is elegible for highscores. |
Returns:
The constructed song object.
Constructor
new(id:String, ?params:Null<SongParams>)
Parameters:
id | The ID of the song to load. |
|---|---|
targetVariation | The variation to load, optional. |
Variables
validScore:Bool = true
Set to false if the song was edited in the charter and should not be saved as a high score.
Methods
cacheCharts(force:Bool = false):Void
Parse and cache the chart for all difficulties of this song.
Parameters:
force | Whether to forcibly clear the list of charts first. |
|---|
getAlbumId(diffId:String, variation:String):String
Input a difficulty ID and a variation ID, and get the album ID.
Parameters:
diffId | |
|---|---|
variation |
Returns:
String
getDifficulty(?diffId:String, ?variation:String, ?variations:Array<String>):Null<SongDifficulty>
Retrieve the metadata for a specific difficulty, including the chart if it is loaded.
Parameters:
diffId | The difficulty ID, such as |
|---|---|
variation | The variation ID to fetch the difficulty for. Or you can use |
variations | A list of variations to fetch the difficulty for. Looks for the first variation that exists. |
Returns:
The difficulty data.
getFirstValidVariation(?diffId:String, ?currentCharacter:PlayableCharacter, ?possibleVariations:Array<String>):Null<String>
Returns the first valid variation that matches both the difficulty id, and the current character / possible input variations
Parameters:
diffId | |
|---|---|
currentCharacter | |
possibleVariations |
Returns:
Null
getRawMetadata():Array<SongMetadata>
Retrieve a list of the raw metadata for the song.
Returns:
The metadata JSON objects for the song's variations.
getVariationsByCharacter(?char:PlayableCharacter):Array<String>
Given that this character is selected in the Freeplay menu, which variations should be available?
Parameters:
char | The playable character to query. |
|---|
Returns:
An array of available variations.
getVariationsByCharacterId(?charId:String):Array<String>
Nearly the same thing as getVariationsByCharacter, but takes a character ID instead.
Parameters:
charId |
|---|
Returns:
Array
See also:
getVariationsByCharacter
listAlbums(variation:String):Map<String, String>
List the album IDs for each variation of the song.
Returns:
A map of variation IDs to album IDs.
listAltInstrumentalIds(difficultyId:String, variationId:String):Array<String>
Return the list of available alternate instrumentals. Scripts can override this, fun.
Parameters:
variationId | |
|---|---|
null | difficultyId |
listDifficulties(?variationId:String, ?variationIds:Array<String>, showLocked:Bool = false, showHidden:Bool = false):Array<String>
List all the difficulties in this song.
Parameters:
variationId | Optionally filter by a single variation. |
|---|---|
variationIds | Optionally filter by multiple variations. |
showLocked | Include charts which are not unlocked |
showHidden | Include charts which are not accessible to the player. |
Returns:
The list of difficulties.
listSuffixedDifficulties(variationIds:Array<String>, ?showLocked:Bool, ?showHidden:Bool):Array<String>
This function is deprecated, Funkin no longer uses suffixed difficulties.
TODO: This line of code makes me sad, but you can't really fix it without a breaking migration.
Returns:
easy, erect, normal-pico, etc.