Hello. I was really interested in your project since I see it can load music but reduce loading times. I would like to ask how I can call this program to play a song within code, I have a function here that calls the api but it does not seem to work. Any solutions?
I'm pretty sure I am using the wrong function. I need something to reduce load times and memory use for the Minetest Zombies Minigame which runs slow due to the over 44MB of music included. 0 . 0
Code: Select all
-- All glory to God, Jesus Christ, and the Holy Spirit.
local function OnboardMusic(inputa, inputb)
local m_name = inputa
local m_length = inputb
for _,player in ipairs (minetest.get_connected_players()) do
local plname = player:get_player_name()
dbgm.send_music_to_player(plname,m_name,dbgm.path .. "/music/")
end
end
function GetSong()
if Map == "prison" then
selection = math.random(1,11)
if selection == 1 then
OnboardMusic("zombies", 104104)
end
if selection == 2 then
OnboardMusic("prison", 251)
end
if selection == 3 then
OnboardMusic("cell_outbreak", 217)
end
if selection == 4 then
OnboardMusic("zombies", 104)
end
if selection == 5 then
OnboardMusic("prison", 251)
end
if selection == 6 then
OnboardMusic("cell_outbreak", 217)
end
if selection == 7 then
OnboardMusic("zombies", 104)
end
if selection == 8 then
OnboardMusic("prison", 251)
end
if selection == 9 then
OnboardMusic("cell_outbreak", 217)
end
if selection == 10 then
OnboardMusic("prison", 251)
end
if selection == 11 then
OnboardMusic("surviving_for_a_while", 230)
end
end
if Map == "hotel" then
selection = math.random(1,11)
if selection == 1 then
OnboardMusic("zombies", 104)
end
if selection == 2 then
OnboardMusic("hotel", 102)
end
if selection == 3 then
OnboardMusic("hotel", 102)
end
if selection == 4 then
OnboardMusic("zombies", 104)
end
if selection == 5 then
OnboardMusic("hotel", 102)
end
if selection == 6 then
OnboardMusic("hotel", 102)
end
if selection == 7 then
OnboardMusic("zombies", 104)
end
if selection == 8 then
OnboardMusic("hotel", 102)
end
if selection == 9 then
OnboardMusic("hotel", 102)
end
if selection == 10 then
OnboardMusic("hotel", 102)
end
if selection == 11 then
OnboardMusic("surviving_for_a_while", 230)
end
end
if Map == "jungle" then
selection = math.random(1,11)
if selection == 1 then
OnboardMusic("zombies", 104)
end
if selection == 2 then
OnboardMusic("jungle", 167)
end
if selection == 3 then
OnboardMusic("jungle", 167)
end
if selection == 4 then
OnboardMusic("jungle", 167)
end
if selection == 5 then
OnboardMusic("jungle", 167)
end
if selection == 6 then
OnboardMusic("jungle", 167)
end
if selection == 7 then
OnboardMusic("zombies", 104)
end
if selection == 8 then
OnboardMusic("jungle", 167)
end
if selection == 9 then
OnboardMusic("jungle", 167)
end
if selection == 10 then
OnboardMusic("jungle", 167)
end
if selection == 11 then
OnboardMusic("surviving_for_a_while", 230)
end
end
if Map == "campsite" then
selection = math.random(1,11)
if selection == 1 then
OnboardMusic("zombies", 104)
end
if selection == 2 then
OnboardMusic("campsite", 188)
end
if selection == 3 then
OnboardMusic("campsite", 188)
end
if selection == 4 then
OnboardMusic("zombies", 104)
end
if selection == 5 then
OnboardMusic("campsite", 188)
end
if selection == 6 then
OnboardMusic("campsite", 188)
end
if selection == 7 then
OnboardMusic("zombies", 104)
end
if selection == 8 then
OnboardMusic("campsite", 188)
end
if selection == 9 then
OnboardMusic("campsite", 188)
end
if selection == 10 then
OnboardMusic("campsite", 188)
end
if selection == 11 then
OnboardMusic("surviving_for_a_while", 230)
end
end
if Map == "shelter" then
selection = math.random(1,11)
if selection == 1 then
OnboardMusic("zombies", 104)
end
if selection == 2 then
OnboardMusic("shelter", 240)
end
if selection == 3 then
OnboardMusic("shelter", 240)
end
if selection == 4 then
OnboardMusic("zombies", 104)
end
if selection == 5 then
OnboardMusic("shelter", 240)
end
if selection == 6 then
OnboardMusic("shelter", 240)
end
if selection == 7 then
OnboardMusic("zombies", 104)
end
if selection == 8 then
OnboardMusic("shelter", 240)
end
if selection == 9 then
OnboardMusic("shelter", 240)
end
if selection == 10 then
OnboardMusic("shelter", 240)
end
if selection == 11 then
OnboardMusic("surviving_for_a_while", 230)
end
end
if Map == "tomb" then
selection = math.random(1,11)
if selection == 1 then
OnboardMusic("the_swarm", 249)
end
if selection == 2 then
OnboardMusic("survival", 212)
end
if selection == 3 then
OnboardMusic("tomb", 453)
end
if selection == 4 then
OnboardMusic("the_swarm", 249)
end
if selection == 5 then
OnboardMusic("survival", 212)
end
if selection == 6 then
OnboardMusic("tomb", 453)
end
if selection == 7 then
OnboardMusic("the_swarm", 249)
end
if selection == 8 then
OnboardMusic("tomb", 453)
end
if selection == 9 then
OnboardMusic("tomb", 453)
end
if selection == 10 then
OnboardMusic("tomb", 453)
end
if selection == 11 then
OnboardMusic("surviving_for_a_while", 230)
end
end
if Map == "vanclerie" then
selection = math.random(1,11)
if selection == 1 then
OnboardMusic("the_swarm", 249)
end
if selection == 2 then
OnboardMusic("survival", 212)
end
if selection == 3 then
OnboardMusic("vanclerie", 116)
end
if selection == 4 then
OnboardMusic("the_swarm", 249)
end
if selection == 5 then
OnboardMusic("survival", 212)
end
if selection == 6 then
OnboardMusic("the_president_is_missing", 169)
end
if selection == 7 then
OnboardMusic("the_swarm", 249)
end
if selection == 8 then
OnboardMusic("vanclerie", 116)
end
if selection == 9 then
OnboardMusic("the_president_is_missing", 169)
end
if selection == 10 then
OnboardMusic("vanclerie", 116)
end
if selection == 11 then
OnboardMusic("surviving_for_a_while", 230)
end
end
if Map == "five" then
selection = math.random(1,11)
if selection == 1 then
OnboardMusic("the_swarm", 249)
end
if selection == 2 then
OnboardMusic("survival", 212)
end
if selection == 3 then
OnboardMusic("five", 121)
end
if selection == 4 then
OnboardMusic("five", 121)
end
if selection == 5 then
OnboardMusic("survival", 212)
end
if selection == 6 then
OnboardMusic("the_pentagon_is_under_attack", 154)
end
if selection == 7 then
OnboardMusic("the_swarm", 249)
end
if selection == 8 then
OnboardMusic("five", 121)
end
if selection == 9 then
OnboardMusic("the_pentagon_is_under_attack", 154)
end
if selection == 10 then
OnboardMusic("five", 121)
end
if selection == 11 then
OnboardMusic("surviving_for_a_while", 230)
end
-- added
end
-- added
end