-- Welcome. I've written this code myself. And as I'm not that skilled of a coder, it may be a bit weird. But it works... somehow --Anyways, you're probably here because you want to add you own music, which is fair enough, the Beam music isn't all thaat exiting --There are instructions in form of notes all over the file. If you experience any issues, feel free to contact me under Inn0centJok3r on BeamNG.com --I hope the notes are helpful enough to allow you to get your stuff working. Have a nice day! --Please read all notes. local M = {} local song_1 local song_2 local songName = "Radio Off" local songLimit = 45 --added later on, self explanitory local listLimit = 3 local volume = 5 local song = 0 local list = 1 local songWasPlaying = 0 local timer = 0 local timeractive = 0 local timerdone = 0 local musicList = "bla" local timermusic = 0 local timerrunning = false local songchanged = false local function playList() if list == 1 then musicList = "Default Music" if song == 1 then songName = "Go one forward to play!" elseif song == 2 then songName = "Piano" if song == 2 and timerdone == 1 then song_2 = obj:createSFXSource("event:>Special>piano_music", "AudioDefaultLoop3D", "PianoSound", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 3 then songName = "Go one forward to play!" elseif song == 4 then songName = "lonle (Credits theme)" if song == 4 and timerdone == 1 then song_2 = obj:createSFXSource("ui/modules/credits/lonle.ogg", "AudioDefaultLoop3D", "RadioSound1", 1) --change the 3rd string (aka RadioSound1 here) when making new music!! You can just go 1 up with the number obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 5 then songName = "Go one forward to play!" elseif song == 6 then songName = "Very Bassy Music" if song == 6 and timerdone == 1 then song_1 = obj:createSFXSource("art/sound/music/Legran_Music_interior", "AudioDefaultLoop3D", "PianoSound", 1) obj:setVolumePitch(song_1, volume, 1) timerdone = 0 end elseif song == 7 then songName = "Go one forward to play!" elseif song == 8 then songName = "Lightrunner Theme Loop" --sadly will play all 5 songs randomly as the files are encrypted in the fmod bank files and idk how to access them individually. if song == 8 and timerdone == 1 then --and taking the extracted files and putting them into this mod to make ot work would be rather iffy in terms of copyright... song_2 = obj:createSFXSource("event:>Music>synthwave", "AudioDefaultLoop3D", "RadioSound2", 1) obj:setVolumePitch(song_2, (volume / 2), 1) --Music by Mark 'TDK' Knight, Copyrighted music. songs included 1:Element No. 10 2:Getting Away 3:Juno Rocks 4:Neon Night Racer 5:Night Driver timerdone = 0 end elseif song == 9 then songName = "Go one forward to play!" elseif song == 10 then songName = "Dicta" if song == 10 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/dicta", "AudioDefaultLoop3D", "RadioSound3", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 11 then songName = "Go one forward to play!" elseif song == 12 then songName = "Merry Christmas Jingle" if song == 12 and timerdone == 1 then song_2 = obj:createSFXSource("art/sounds/mod_winter/Merry_Christmas_Jingle_Filtered_01.protected.ogg", "AudioDefaultLoop3D", "RadioSound4", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 13 then songName = "Go one forward to play!" elseif song == 14 then songName = "Deck The Halls Bells" if song == 14 and timerdone == 1 then song_2 = obj:createSFXSource("art/sounds/mod_winter/Deck_the_Halls_Bells_Filtered.protected.ogg", "AudioDefaultLoop3D", "RadioSound5", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end end elseif list == 2 then musicList = "3 Doors Down" if song == 1 then songName = "Go one forward to play!" elseif song == 2 then songName = "It's Not My Time" if song == 2 and timerdone == 1 then song_1 = obj:createSFXSource("art/sound/music/It's Not My Time", "AudioDefaultLoop3D", "RadioSound2", 1) obj:setVolumePitch(song_1, volume, 1) timerdone = 0 end elseif song == 3 then songName = "Go one forward to play!" elseif song == 4 then songName = "Away From The Sun" if song == 4 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Away From The Sun", "AudioDefaultLoop3D", "RadioSound3", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 5 then songName = "Go one forward to play!" elseif song == 6 then songName = "Dangerous Game" if song == 6 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Dangerous Game", "AudioDefaultLoop3D", "RadioSound4", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 7 then songName = "Go one forward to play!" elseif song == 8 then songName = "Going Down In Flames" if song == 8 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Going Down In Flames", "AudioDefaultLoop3D", "RadioSound5", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 9 then songName = "Go one forward to play!" elseif song == 10 then songName = "Here Without You" if song == 10 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Here Without You", "AudioDefaultLoop3D", "RadioSound6", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 11 then songName = "Go one forward to play!" elseif song == 12 then songName = "I Feel You" if song == 12 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/I Feel You", "AudioDefaultLoop3D", "RadioSound7", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 13 then songName = "Go one forward to play!" elseif song == 14 then songName = "Running Out Of Days" if song == 14 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Running Out Of Days", "AudioDefaultLoop3D", "RadioSound8", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 15 then songName = "Go one forward to play!" elseif song == 16 then songName = "Sarah Yellin'" if song == 16 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Sarah Yellin'", "AudioDefaultLoop3D", "RadioSound9", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 17 then songName = "Go one forward to play!" elseif song == 18 then songName = "The Road I'm On" if song == 18 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/The Road I'm On", "AudioDefaultLoop3D", "RadioSound10", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 19 then songName = "Go one forward to play!" elseif song == 20 then songName = "This Time" if song == 20 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/This Time", "AudioDefaultLoop3D", "RadioSound11", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 21 then songName = "Go one forward to play!" elseif song == 22 then songName = "Ticket To Heaven" if song == 22 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Ticket To Heaven", "AudioDefaultLoop3D", "RadioSound12", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 23 then songName = "Go one forward to play!" elseif song == 24 then songName = "Be Somebody" if song == 24 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Be somebody", "AudioDefaultLoop3D", "RadioSound13", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 25 then songName = "Go one forward to play!" elseif song == 26 then songName = "Behind Those Eyes" if song == 26 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Behind Those Eyes", "AudioDefaultLoop3D", "RadioSound14", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 27 then songName = "Go one forward to play!" elseif song == 28 then songName = "Father's Son" if song == 28 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Father's Son", "AudioDefaultLoop3D", "RadioSound15", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 29 then songName = "Go one forward to play!" elseif song == 30 then songName = "Here By Me" if song == 30 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Here By Me" "AudioDefaultLoop3D", "RadioSound16", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 31 then songName = "Go one forward to play!" elseif song == 32 then songName = "It's Not Me" if song == 32 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/It's Not Me", "AudioDefaultLoop3D", "RadioSound17", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 33 then songName = "Go one forward to play!" elseif song == 34 then songName = "Landing In London (ft. Bob Seger)" if song == 34 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Landing In London(ft. Bob Seger)", "AudioDefaultLoop3D", "RadioSound18", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 35 then songName = "Go one forward to play!" elseif song == 36 then songName = "Live For Today" if song == 36 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Live For Today", "AudioDefaultLoop3D", "RadioSound19", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 37 then songName = "Go one forward to play!" elseif song == 38 then songName = "My World" if song == 38 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/My World", "AudioDefaultLoop3D", "RadioSound20", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 39 then songName = "Go one forward to play!" elseif song == 40 then songName = "Never Will I Break" if song == 40 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Never Will I Break", "AudioDefaultLoop3D", "RadioSound21", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 41 then songName = "Go one forward to play!" elseif song == 42 then songName = "Right Where I Belong" if song == 42 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Right Where I Belong", "AudioDefaultLoop3D", "RadioSound22", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 43 then songName = "Go one forward to play!" elseif song == 44 then songName = "The Real Life" if song == 44 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/The Real Life", "AudioDefaultLoop3D", "RadioSound23", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end end elseif list == 3 then musicList = "AJR" if song == 1 then songName = "Go one forward to play!" elseif song == 2 then songName = "100 Bad Days" if song == 2 and timerdone == 1 then song_1 = obj:createSFXSource("art/sound/music/100 Bad Days", "AudioDefaultLoop3D", "RadioSound2", 1) obj:setVolumePitch(song_1, volume, 1) timerdone = 0 end elseif song == 3 then songName = "Go one forward to play!" elseif song == 4 then songName = "Bang!" if song == 4 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Bang!", "AudioDefaultLoop3D", "RadioSound3", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 5 then songName = "Go one forward to play!" elseif song == 6 then songName = "Burn The House Down" if song == 6 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Burn The House Down", "AudioDefaultLoop3D", "RadioSound4", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 7 then songName = "Go one forward to play!" elseif song == 8 then songName = "I'm Not Famous" if song == 8 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/I'm Not Famous", "AudioDefaultLoop3D", "RadioSound5", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 9 then songName = "Go one forward to play!" elseif song == 10 then songName = "I'm Ready" if song == 10 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/I'm Ready", "AudioDefaultLoop3D", "RadioSound6", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 11 then songName = "Go one forward to play!" elseif song == 12 then songName = "Sober Up" if song == 12 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Sober Up", "AudioDefaultLoop3D", "RadioSound7", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end elseif song == 13 then songName = "Go one forward to play!" elseif song == 14 then songName = "Weak" if song == 14 and timerdone == 1 then song_2 = obj:createSFXSource("art/sound/music/Weak", "AudioDefaultLoop3D", "RadioSound8", 1) obj:setVolumePitch(song_2, volume, 1) timerdone = 0 end end end local function updateGFX(dt) if timeractive == 1 then --This timer just exists to space out the input of a control and execution of the music playlist timer = timer + dt --somehow this timer is needed to make stuff play the first time you go on it if timer >= 0.1 then timerdone = 1 playList() timer = 0 timeractive = 0 end end if electrics.values['reverseactive'] == 1 then --stuff for the infotainment screen timermusic = 0 songchanged = false timerrunning = false end if timerrunning == true and electrics.values['reverseactive'] == 0 then timermusic = timermusic + dt if songchanged == true then timermusic = 0 songchanged = false end if timermusic >= 5 then electrics.values['musicscreenactive'] = 0 timerrunning = false timermusic = 0 end end electrics.values["radio"] = songName end local function moreVol() if volume <= 14 then volume = volume + 1 gui.message("Radio Volume: " .. volume) playList() if song_2 ~= nil then obj:setVolumePitch(song_2, 0, 1) end if song_1 ~= nil then obj:setVolumePitch(song_1, 0, 1) end song_2 = nil song_1 = nil timeractive = 1 end if volume >= 15 then gui.message("Max Radio Volume: " .. volume) playList() if song_2 ~= nil then obj:setVolumePitch(song_2, 0, 1) end if song_1 ~= nil then obj:setVolumePitch(song_1, 0, 1) end song_2 = nil song_1 = nil timeractive = 1 end end local function lessVol() if volume >= 1 then volume = volume - 1 gui.message("Radio Volume: " .. volume) playList() if song_2 ~= nil then obj:setVolumePitch(song_2, 0, 1) end if song_1 ~= nil then obj:setVolumePitch(song_1, 0, 1) end song_2 = nil song_1 = nil timeractive = 1 end if volume == 0 then gui.message("Lowest Radio Volume: " .. volume) playList() if song_2 ~= nil then obj:setVolumePitch(song_2, 0, 1) end if song_1 ~= nil then obj:setVolumePitch(song_1, 0, 1) end song_2 = nil song_1 = nil timeractive = 1 end end local function nextSong() song = song + 1 songWasPlaying = 1 if song >= songLimit then --here is the max song limit. After the 12th one it'll go back to 1. If you want more songs per list, just increase the limit here UPDATE: Has been replace by value, look on top to change song = 1 songMessage = 0 end if song ~=0 then playList() if song_2 ~= nil then obj:setVolumePitch(song_2, 0, 1) end if song_1 ~= nil then obj:setVolumePitch(song_1, 0, 1) end song_2 = nil song_1 = nil if songName == "Go one forward to play!" then gui.message(songName) else gui.message("Next song playing. Now playing: " .. songName .. " (" .. song/2 .. "/" .. songLimit-8 .. ")") --increase the -4 the more music you add. Basically, -1 is the base due to the "go back to song 1" system -- -1 is the base value. add one more to that for every song added! if electrics.values['reverseactive'] == 0 then --infotainment screen stuff timerrunning = true electrics.values['musicscreenactive'] = 1 songchanged = true end end timeractive = 1 end end local function pastSong() if song ~=0 then song = song - 1 end if song == 0 and songWasPlaying ==1 then gui.message("Radio off") songName = "Radio Off" songMessage = 0 songWasPlaying = 0 if song_2 ~= nil then obj:setVolumePitch(song_2, 0, 1) end if song_1 ~= nil then obj:setVolumePitch(song_1, 0, 1) end end if song ~=0 then playList() if song_2 ~= nil then obj:setVolumePitch(song_2, 0, 1) end if song_1 ~= nil then obj:setVolumePitch(song_1, 0, 1) end song_2 = nil song_1 = nil if songName == "Go one forward to play!" then gui.message(songName) else gui.message("Past song playing. Now playing: " .. songName .. " (" .. song/2 .. "/" .. songLimit-7 .. ")") --increase the -7 the more music you add. Basically, -1 is the base due to the "go back to song 1" system if electrics.values['reverseactive'] == 0 then timerrunning = true electrics.values['musicscreenactive'] = 1 songchanged = true end end -- -1 is the base value. add one more to that for every song added! timeractive = 1 end end local function nextList() if list >= listLimit then --To add more playlists, increase this default value of 2. UPDATE: replaced by value, look on top to change list = 1 end list = list + 1 song = 0 playList() if song_2 ~= nil then obj:setVolumePitch(song_2, 0, 1) end if song_1 ~= nil then obj:setVolumePitch(song_1, 0, 1) end song_2 = nil song_1 = nil gui.message("Next music list selected: " .. musicList .. " (" .. list .. "/" .. listLimit .. ")") end local function pastList() if list ~=1 then list = list - 1 song = 0 playList() if song_2 ~= nil then obj:setVolumePitch(song_2, 0, 1) end if song_1 ~= nil then obj:setVolumePitch(song_1, 0, 1) end song_2 = nil song_1 = nil gui.message("Past music list selected: " .. musicList .. " (" .. list .. "/" .. listLimit .. ")") end end local function onInit() volume = 5 song = 0 list = 1 songWasPlaying = 0 timer = 0 timeractive = 0 timerdone = 0 timermusic = 0 electrics.values['musicscreenactive'] = 0 timerrunning = false songchanged = false end -- public interface M.nextSong = nextSong M.pastSong = pastSong M.nextList = nextList M.pastList = pastList M.lessVol = lessVol M.moreVol = moreVol M.playList = playList M.onInit = onInit M.updateGFX = updateGFX return M