[Solved] Creating custom option for sound effect in settings

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
kostek00
Regular
Posts: 131
Joined: Wed Mar 28, 2018 5:54 pm
Contact:

[Solved] Creating custom option for sound effect in settings

#1 Post by kostek00 »

I'm would like to create an options in settings that turns on/off onomatopeias in text.

Let's say I have such line:

Code: Select all

"I **PUNCH** AM **PUNCH** EVERYTHING **PUNCH** TO **PUNCH** YOU **PUNCH**!"
With onomatopeias turned off I would have:

Code: Select all

"I AM EVERYTHING TO YOU!"
I know how to check for it (noob version):

Code: Select all

"I"
if some_option == True:
	extend " **PUNCH**"
play sound "punch.ogg"
extend " AM"
if some_option == True:
	extend " **PUNCH**"
play sound "punch.ogg"
and so on...
My problem is I don't know how to register such option in settings. I will appreciate any help.
Last edited by kostek00 on Thu Dec 27, 2018 9:42 am, edited 1 time in total.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Creating custom option for sound effect in settings

#2 Post by Per K Grok »

kostek00 wrote: Sun Dec 23, 2018 4:27 pm I'm would like to create an options in settings that turns on/off onomatopeias in text.

Let's say I have such line:

Code: Select all

"I **PUNCH** AM **PUNCH** EVERYTHING **PUNCH** TO **PUNCH** YOU **PUNCH**!"
With onomatopeias turned off I would have:

Code: Select all

"I AM EVERYTHING TO YOU!"
I know how to check for it (noob version):

Code: Select all

"I"
if some_option == True:
	extend " **PUNCH**"
play sound "punch.ogg"
extend " AM"
if some_option == True:
	extend " **PUNCH**"
play sound "punch.ogg"
and so on...
My problem is I don't know how to register such option in settings. I will appreciate any help.
Set up your variable at the star of the script.rpy file.

default some_option = True

Then go to screen.rpy
find screen preferences():
find
## Additional vboxes of type "radio_pref" or "check_pref" can be
## added here, to add additional creator-defined preferences.
and add

Code: Select all

                vbox:
                    style_prefix "radio"
                    label _("onomatopeias in text")
                    textbutton _("On") action SetVariable("some_option", True)
                    textbutton _("Off") action SetVariable("some_option", False)

User avatar
kostek00
Regular
Posts: 131
Joined: Wed Mar 28, 2018 5:54 pm
Contact:

Re: Creating custom option for sound effect in settings

#3 Post by kostek00 »

Sorry for late response. It's working as intended. Thank you very much.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]