How do you change bar increment/decrement value when using keyboard?

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
henvu50
Veteran
Posts: 322
Joined: Wed Aug 22, 2018 1:22 am
Contact:

How do you change bar increment/decrement value when using keyboard?

#1 Post by henvu50 » Thu Oct 20, 2022 5:49 pm

In a new renpy project. Go to preferences and music volume. Then press enter and slide the music volume slider left and right. It will increment and decrement by a value of 0.1 .. How can you change this value to 0.05, instead of 0.1?

Code: Select all

if config.has_music:
  label _("Music Volume")
     hbox:
        bar value Preference("music volume")
        kb_increment 0.05   #hypothetical how would you do this?
        kb_decrement 0.05  #hypothetical how would you do this?

User avatar
Tess
Newbie
Posts: 23
Joined: Thu Aug 04, 2022 3:43 pm
Projects: The Songbird Guild
Organization: Yurisoft
Github: wainwt2
Discord: Tess#7782
Contact:

Re: How do you change bar increment/decrement value when using keyboard?

#2 Post by Tess » Thu Oct 20, 2022 10:19 pm

This is what I came up with:

Code: Select all

#At the beginning of the screens file
init python:
    def set_music_volume(vol):
        preferences.set_volume("music",vol)

#In the preferences screen  
if config.has_music:
	label _("Music Volume")
	default music_volume = 1.0
	hbox:
	 bar adjustment ui.adjustment(value=music_volume,range=1.0,adjustable=True,step=0.05,changed=set_music_volume)
I don't think it's possible to hand MixerValue("music") or Preference("music volume") directly to the ui.adjustment object, it kept complaining about wanting an int or float rather than a MixerValue object.

henvu50
Veteran
Posts: 322
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: How do you change bar increment/decrement value when using keyboard?

#3 Post by henvu50 » Thu Oct 20, 2022 11:30 pm

Tess wrote:
Thu Oct 20, 2022 10:19 pm
This is what I came up with:

Code: Select all

#At the beginning of the screens file
init python:
    def set_music_volume(vol):
        preferences.set_volume("music",vol)

#In the preferences screen  
if config.has_music:
	label _("Music Volume")
	default music_volume = 1.0
	hbox:
	 bar adjustment ui.adjustment(value=music_volume,range=1.0,adjustable=True,step=0.05,changed=set_music_volume)
I don't think it's possible to hand MixerValue("music") or Preference("music volume") directly to the ui.adjustment object, it kept complaining about wanting an int or float rather than a MixerValue object.
Thanks for trying. Maybe we have to edit the main Renpy PY files to change the step value.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]