Header menu logo BaboonAPI

Looking up tracks

If you're a mod trying to determine things about tracks, you'll probably be looking for some way to look up information about that track. Look no further than the TrackLookup API!

Basic usage

Simply call TrackLookup.lookup with the trackref you want to look up:

open BaboonAPI.Hooks.Tracks

let track = TrackLookup.lookup "mare"

track.trackname_long // => "Old Gray Mare"
// C#
var track = TrackLookup.lookup("mare");

track.trackname_long // => "Old Gray Mare"

Note that this method will throw an exception if the track can't be found. If you want to handle this, use TrackLookup.tryLookup instead:

let maybeTrack = TrackLookup.tryLookup "mare"

maybeTrack |> Option.map (fun track -> track.trackname_long)
// => Some("Old Gray Mare")
var maybeTrack = TrackLookup.tryLookup("mare")
OptionModule.Map(track => track.trackname_long, maybeTrack)
// => Some("Old Gray Mare")

Checking whether a track is custom

While BaboonAPI has no knowledge of custom tracks itself, you can use an is pattern to conditionally cast the returned TromboneTrack to a subclass.

For example, TrombLoader's custom track class is named CustomTrack:

open TrombLoader.CustomTracks

let bakaMitaiTrack = TrackLookup.lookup "BakaMitai"
match bakaMitaiTrack with
| :? CustomTrack as ct ->
    // This is a TrombLoader track!
    ct.folderPath
| track ->
    // Not a TrombLoader track - something else!
    track.trackname_long
// C#
var track = TrackLookup.lookup("BakaMitai");
if (track is CustomTrack ct)
{
    // This track is a TrombLoader track!
    ct.folderPath // returns the path to the folder containing this track
}

Looking up scores

If you want to look up locally saved high scores for a track, you can use TrackLookup.trackScore:

let possibleScores = TrackLookup.lookupScore "BakaMitai"

If the track has been played at least once, you'll get a Some(SavedTrackScore) back! Otherwise, you'll get None. Note that the track might exist even if its score hasn't been saved - use tryLookup if you want to check that!

match possibleScores with
| Some score ->
    let lastFiveHighScores = score.highScores
    let highestRank = score.highestRank
    // Now we have highscores!
    ()
| None ->
    // Track wasn't found in score storage!
    ()

Additional utilities

If you need a SingleTrackData for whatever reason, you can convert any TromboneTrack easily:

let trackData = TrackLookup.toTrackData bakaMitaiTrack
trackData.trackname_long // => "Baka Mitai"
namespace BaboonAPI
namespace BaboonAPI.Hooks
namespace BaboonAPI.Hooks.Tracks
val track: TromboneTrack
module TrackLookup from BaboonAPI.Hooks.Tracks
<summary> Public hooks to look up registered tracks </summary>
val lookup: trackref: string -> TromboneTrack
<summary> Look up a track by trackref </summary>
property TromboneTrack.trackname_long: string with get
val maybeTrack: TromboneTrack option
val tryLookup: trackref: string -> TromboneTrack option
<summary> Look up a track by trackref, returning None if the track doesn't exist. </summary>
module Option from Microsoft.FSharp.Core
val map: mapping: ('T -> 'U) -> option: 'T option -> 'U option
namespace TrombLoader
namespace TrombLoader.CustomTracks
val bakaMitaiTrack: TromboneTrack
Multiple items
type CustomTrack = interface TromboneTrack new: trackRef: string * name: string * shortName: string * author: string * description: string * endpoint: float32 * year: int * genre: string * difficulty: int * tempo: float32 * backgroundMovement: string * savednotespacing: int * timesig: int * lyrics: List<Lyric> * note_color_start: float32 array * note_color_end: float32 array * notes: float32 array array * bgdata: float32 array array -> unit member IsVisible: unit -> bool member LoadChart: unit -> SavedLevel member LoadTrack: unit -> LoadedTromboneTrack val author: string val description: string val endpoint: float32 val name: string val shortName: string ...

--------------------
CustomTrack(trackRef: string, name: string, shortName: string, author: string, description: string, endpoint: float32, year: int, genre: string, difficulty: int, tempo: float32, backgroundMovement: string, savednotespacing: int, timesig: int, lyrics: System.Collections.Generic.List<CustomTrack.Lyric>, note_color_start: float32 array, note_color_end: float32 array, notes: float32 array array, bgdata: float32 array array) : CustomTrack
val ct: CustomTrack
property CustomTrack.folderPath: string with get, set
val possibleScores: TrackLookup.SavedTrackScore option
val lookupScore: trackref: string -> TrackLookup.SavedTrackScore option
<summary>Get the current high scores for a track.</summary>
<returns>None if there is no saved data for the trackref, Some otherwise.</returns>
union case Option.Some: Value: 'T -> Option<'T>
val score: TrackLookup.SavedTrackScore
val lastFiveHighScores: int list
TrackLookup.SavedTrackScore.highScores: int list
val highestRank: string
TrackLookup.SavedTrackScore.highestRank: string
union case Option.None: Option<'T>
val trackData: SingleTrackData
val toTrackData: track: TromboneTrack -> SingleTrackData
<summary> Convert a TromboneTrack into a SingleTrackData </summary>
field SingleTrackData.trackname_long: string

Type something to start searching.