Allowing the player to choose the music on this case?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Allowing the player to choose the music on this case?

#1 Post by Nanahs »

I'm going to add a phone option on my game, and I wanted to allow the player to choose their "ringtone".

There's like "ringtone1.mp3", "ringtone2.mp3" and "ringtone3.mp3" files.

Then when there's "play ringtone", it will play the chosen one. Is it possible?

Sorry guys, I'm kinda slow now. It's been a long a time since I used Renpy.

Thank you.

User avatar
HotMango
Regular
Posts: 28
Joined: Wed Jan 15, 2020 10:36 pm
Skype: aboodal3deny
Contact:

Re: Allowing the player to choose the music on this case?

#2 Post by HotMango »

It is "possible". However, I know of no 'proper' way to do it.

Personally, I'd define a variable that handles the player's choice, something like this:

Code: Select all

default pchoice = ""

label start: #or whatever it is called. Sorry, been a long time since I last used the Engine.
	#I forgot how to make a menu but imagine if this is a menu
	
	menu:
	Which ringtone do you want?
		1:
			jump ring1
		2:
			jump ring2
		3:
			jump ring3
			
label ring1:
	$pchoice = ""ring1"
	jump continue
	
label ring2:
	$pchoice = "ring2"
	jump continue
	
label ring3:
	$pchoice = "ring3"
	jump continue
label continue:
	"bla bla bla"
	if pchoice == ring1:
		play music "ring1.mp3" 
	if pchoice == ring2:
		play music "ring2.mp3"
	if pchoice == ring3:
		play music "ring3.mp3"
Again, sorry for the wrong codes, my memory is a bit hazy since it's been a long time. I hope this helps!

User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: Allowing the player to choose the music on this case?

#3 Post by Nanahs »

HotMango wrote: Sat Aug 15, 2020 2:18 am It is "possible". However, I know of no 'proper' way to do it.

Personally, I'd define a variable that handles the player's choice, something like this:

Code: Select all

default pchoice = ""

label start: #or whatever it is called. Sorry, been a long time since I last used the Engine.
	#I forgot how to make a menu but imagine if this is a menu
	
	menu:
	Which ringtone do you want?
		1:
			jump ring1
		2:
			jump ring2
		3:
			jump ring3
			
label ring1:
	$pchoice = ""ring1"
	jump continue
	
label ring2:
	$pchoice = "ring2"
	jump continue
	
label ring3:
	$pchoice = "ring3"
	jump continue
label continue:
	"bla bla bla"
	if pchoice == ring1:
		play music "ring1.mp3" 
	if pchoice == ring2:
		play music "ring2.mp3"
	if pchoice == ring3:
		play music "ring3.mp3"
Again, sorry for the wrong codes, my memory is a bit hazy since it's been a long time. I hope this helps!
Thank you so much! I'll try that :)

Post Reply

Who is online

Users browsing this forum: Google [Bot]