Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -------------------------------------------------
- --[[ jukebox.lua v0.2 by KBM-Quine ]]--
- --[[ "custom" overworld music library ]]--
- -------------------------------------------------
- local jukebox = {}
- local curMusicID = mem(0x00B2C5D8, FIELD_WORD)
- local curTrack = -1
- local function resolveTrack(string) -- to make default tracks easier to replace
- local returnString = Misc.resolveSoundFile(string) or Misc.resolveSoundFile("music\\" .. string)
- return returnString
- end
- local tracks = {
- [0] = nil,
- [1] = resolveTrack("smb3-world1"),
- [2] = resolveTrack("smb3-world4"),
- [3] = resolveTrack("smb3-world7"),
- [4] = resolveTrack("smw-worldmap"),
- [5] = resolveTrack("nsmb-world"),
- [6] = resolveTrack("smb3-world2"),
- [7] = resolveTrack("smw-forestofillusion"),
- [8] = resolveTrack("smb3-world3"),
- [9] = resolveTrack("smb3-world8"),
- [10] = resolveTrack("smb3-world6"),
- [11] = resolveTrack("smb3-world5"),
- [12] = resolveTrack("smw-special"),
- [13] = resolveTrack("smw-bowserscastle"),
- [14] = resolveTrack("smw-starroad"),
- [15] = resolveTrack("smw-yoshisisland"),
- [16] = resolveTrack("smw-vanilladome"),
- }
- function jukebox.setTrack(id, filepath)
- tracks[id] = filepath
- end
- function jukebox.getTrack(id)
- return tracks[id]
- end
- function jukebox.getPlayingTrack()
- return tracks[curTrack]
- end
- function jukebox.getPlayingTrackID()
- return curTrack
- end
- function jukebox.setMusicBox(id, x, y)
- if not isOverworld then return end
- local m = Musicbox.getIntersecting(x, y, x+32, y+32)[1]
- m.id = id
- end
- function jukebox.playTrack(trackID)
- Audio.MusicStop()
- if trackID > 0 then -- use 0 to allow making the music stop
- Audio.MusicOpen(tracks[trackID])
- Audio.MusicPlay()
- curMusicID = trackID
- curTrack = trackID
- else
- curTrack = 0
- end
- end
- function jukebox.onInitAPI()
- registerEvent(jukebox, "onStart")
- registerEvent(jukebox, "onTick")
- registerEvent(jukebox, "onExit")
- end
- function jukebox.onStart()
- if not isOverworld then return end
- Audio.SeizeStream(-1)
- end
- function jukebox.onTick()
- if not isOverworld then return end
- curMusicID = mem(0x00B2C5D8, FIELD_WORD) -- to allow the var to update
- Text.printWP(curTrack, 0,20, 6)
- Text.printWP(curMusicID, 0,0, 6)
- if not (curTrack == curMusicID) then
- jukebox.playTrack(curMusicID)
- end
- end
- function jukebox.onExit()
- if not isOverworld then return end
- curTrack = -1
- Audio.MusicStop()
- Audio.ReleaseStream(-1)
- end
- return jukebox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement