Creating a volume button instead of a slider?

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
Bryy
Veteran
Posts: 407
Joined: Thu Dec 20, 2012 10:12 pm
Completed: 30+ games so far
Projects: Furry Shakespeare
Organization: Stegalosaurus Game Development
Location: Portage, MI
Contact:

Creating a volume button instead of a slider?

#1 Post by Bryy »

Instead of a slider for volume, is it possible to make a set of buttons? An up arrow button and a down arrow button? With corresponding text that goes "1%", "2%", etc.?

Right now, I'm dealing with a slider that seems to extend way past its image, all the way to the end of my computer screen.

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Creating a volume button instead of a slider?

#2 Post by IrinaLazareva »

something like...

Code: Select all

default mvol = .3
screen euqvi():
    $ renpy.music.set_volume(mvol, channel='music')
    $ mvolreal = int(mvol*100)
    vbox at topleft:
        text 'volume [mvolreal] %'
        textbutton '^' action SetVariable('mvol', mvol + .01 if mvol < .99 else 1.0)
        textbutton 'v' action SetVariable('mvol', mvol - .01 if mvol > .01 else 0.0)

label start:
    play music 'testmusic.mp3'
    show screen euqvi
    pause
https://renpy.org/doc/html/audio.html#r ... set_volume
https://renpy.org/doc/html/screen_actio ... etVariable

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Creating a volume button instead of a slider?

#3 Post by Imperf3kt »

If you want the slider to not use the whole screen, place it inside something, like a vbox that has an xmaximum set.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Bryy
Veteran
Posts: 407
Joined: Thu Dec 20, 2012 10:12 pm
Completed: 30+ games so far
Projects: Furry Shakespeare
Organization: Stegalosaurus Game Development
Location: Portage, MI
Contact:

Re: Creating a volume button instead of a slider?

#4 Post by Bryy »

Thank you both.

Post Reply

Who is online

Users browsing this forum: Ocelot