Using SensitiveIf

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
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Using SensitiveIf

#1 Post by Imperf3kt »

I've heavily customised the GUI as part of a job I'm working on, and I have a need to make the "save" button greyed out if you're on the save screen or in the main menu context. I've tried a few variations, but nothing I'm using is working.

Can anybody point out how to properly use SensitiveIf() ?

I've currently got this, but it does nothing (including not throwing any errors)

Code: Select all

action [ShowMenu("save"), SensitiveIf(renpy.get_screen is not ("save") or renpy.get_screen is not ("MainMenu"))]
I also tried this, but the results were identical:

Code: Select all

action [ShowMenu("save"), SensitiveIf(not renpy.get_screen("save") or not renpy.get_screen("MainMenu"))]
Or am I completely misunderstanding the documentation (it is 10am after all and I've only had one cup of coffee)
In case it helps, I need something akin to action MainMenu(), where if it is on the screen it will send you to, you cannot focus the button. Currently, the following workaround does the trick, but I'd like a less clunky solution if possible.

Code: Select all

        if not renpy.get_screen("save"):
            imagebutton:
                idle "images/Buttons & Graphics/Text Buttons/Save_Select_Off.png" 
                hover "images/Buttons & Graphics/Text Buttons/Save_Select_On.png"
                action ShowMenu("save")
                tooltip "Save your progress"
        else:
            imagebutton:
                idle "images/Buttons & Graphics/Text Buttons/Save_Select_Off.png" 
                hover "images/Buttons & Graphics/Text Buttons/Save_Select_On.png"
                action NullAction()
                tooltip "Save your progress"
                
If I use NullAction instead of NullAction(), it closes the save screen if I'm on it, hmm
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
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Using SensitiveIf

#2 Post by Remix »

You could just use If()

action If( renpy.get_screen("save"), NullAction(), ShowMenu("save") )
# If( condition, true action(s), false action(s) )

or set the sensitive attribute:

sensitive ( not renpy.get_screen("save") )

Other than that, the SensitiveIf(not renpy.get_screen("save") or not renpy.get_screen("MainMenu")) with or changed to and should be ok
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Mingus