Slider percentages

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
Valge
Newbie
Posts: 2
Joined: Mon Dec 10, 2018 9:02 am
Contact:

Slider percentages

#1 Post by Valge »

Hello! Is it possible to attach a percentage to such sliders?

Code: Select all

screen preferences():

    tag menu

    imagemap:   
        ground "gui/prefbg.png"
        idle "gui/prefbutton_idle.png"
        hover "gui/prefbg_hover.png"
        selected_idle "gui/prefbutton_selected.png" 
        selected_hover "gui/prefbutton_selected.png" 
        alpha False
        
        hotspot (178, 381, 488, 104) action Preference("display", "fullscreen")
        hotspot (178, 278, 488, 104) action Preference("display", "window")
        hotspot (178, 617, 488, 185) action Preference("skip", "seen")
        hotspot (178, 801, 488, 164) action Preference("skip", "all")
        hotspot (64, 958, 254, 84) action Return()
        
        bar pos (1100, 860) value Preference("text speed") style "pref_slider"
        bar pos (1100, 500) value Preference("sound volume") style "pref_slider"
        bar pos (1100, 300) value Preference("music volume") style "pref_slider"
        bar pos (1100, 680) value Preference("auto-forward time") style "pref_slider"

init -2 python:
    style.pref_slider.left_bar = "gui/prefbar_full.png"
    style.pref_slider.right_bar = "gui/prefbar_empty.png"

    style.pref_slider.xmaximum = 621
    style.pref_slider.ymaximum = 44
    style.pref_slider.thumb = "gui/prefthumb.png"
    style.pref_slider.thumb_offset = 4
    style.pref_slider.thumb_shadow = None
Image

philat
Eileen-Class Veteran
Posts: 1900
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Slider percentages

#2 Post by philat »

The preferences are all variables, so just find them and use them to calculate percentage. Volumes are floats between 0.0 and 1.0 anyway, so that's easy.

Post Reply

Who is online

Users browsing this forum: No registered users