How to loop a sound?

In the main menu of my game i’ve got a soundtrack but its only about 30s long. I would like my soundtrack to repeat in an infinate loop. I know when the sound finishes it automatically sends the message sound_done back to the sender of play_sound, so i made a script below, do you know why this doesn’t work?

function on_message(self, message_id, message, sender)
	if message_id == "sound_done" then 
		msg.post("/go#main_menu1", "play_sound")
	end
end

Have you looked at the sound manual? You could just set the track to loop.

2 Likes
if message_id == "sound_done" then 

Regardless, one issue that may prevent this working is that message_ids are hashes, not strings.

I think you know this, because you’ve handled messages before! I note that this is the fourth thread you have started today. You should slow down and take some time to try to debug things yourself. Read the manuals and the API documentation. These are great resources that will enable you to learn how to do things.

5 Likes

Also learn to use the debugger! The debugger would help you solve this issue since you can inspect the types of all variables.

5 Likes

I was reading a forum and came across rubber duck debugging. It seemed kinda wired but also pretty practical. Have u guys found a specific way you approach debugging programs or does it change depending on what the bug is?