How do I tie a registered dbgm song to a function?

Post Reply
ChristienChapman
Member
Posts: 117
Joined: Sat May 28, 2022 00:04

How do I tie a registered dbgm song to a function?

by ChristienChapman » Post

My latest project is 77% complete. I just need to reduce memory use by using the dynamic background music library. I have been trying various things but cannot get it to work when I call a function. Essentially, I need to be able to tell dbgm to play a song when a function calls for it to be played.

(Note dbgm.play is a placeholder for whatever the appropriate function is called...)

Example:

function getSong()

if DataPointMap.MapToPlay == "prison" then
selection = math.random(1,3)

if selection == 1 then
dbgm.play("prison")
end

if selection == 2 then
dbgm.play("cell_outbreak")
end

if selection == 3 then
dbgm.play("zombies")
end


end

end

Whoever helps solve this issue will be given credit in my project.
God bless you.

List of releases:
Minetest Zombies Minigame - viewtopic.php?f=9&t=28442&p=412633#p412633

- > cdb_1d60e1a03f83

User avatar
bosapara
Member
Posts: 637
Joined: Fri Apr 07, 2017 08:49

Re: How do I tie a registered dbgm song to a function?

by bosapara » Post

>I just need to reduce memory use by using the dynamic background music library.

No way to reduce memory with current version of engine, mods can't help with it. When all the sounds are loaded you will still get overflowing RAM.
I don't use background sounds by this reason (until it's not fixed).

User avatar
MisterE
Member
Posts: 693
Joined: Sun Feb 16, 2020 21:06
GitHub: MisterE123
IRC: MisterE
In-game: MisterE

Re: How do I tie a registered dbgm song to a function?

by MisterE » Post

my advice would be to implement the dynamic media yourself. dbgm is a mod to abstract away all the decision-making for when to play a song.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests