[Solved] deactivating screen button...

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
GMHLee
Newbie
Posts: 16
Joined: Thu Aug 25, 2022 7:00 am
Contact:

[Solved] deactivating screen button...

#1 Post by GMHLee » Wed Aug 31, 2022 11:34 am

Hi there,

Right I've scoured for hours on google, looked at the renpy docs and nada.

in my script.rpy I have

Code: Select all

show screen jewel_button with dissolve

fluff code...

call screen select_girl with dissolve
I need to deactivate the jewel_button when the select_girl screen is active.

In screens.rpy

Code: Select all

screen jewel_button:
    imagebutton auto "jewel_%s.png":
        xpos 0
        ypos 0
        if select_girl_active == False:
            action Show("cards", dissolve)

...

screen select_girl:
    $select_girl_active = True
    add "necklace2.png"
   ...
jewel_button calls up a another screen when you click it.
However when I call the select_girl screen I don't want the jewel_button to be active.

As you can see from above code, it's already hidden with the necklace2.png getting called.
I've tried the doing the if statement which doesn't work (I have an idea why but know why doesn't really help).

I've tried hide jewel_button just under call select_girl in script.rpy (well it still remains active so no good)

I've tried

Code: Select all

 showif select_girl_active == False:
   screen jewel_button
,
but that returns an error cause I'm pretty sure the syntax is incorrect but you try and google examples and all i'm lead to is the renpy doc page which has:

Code: Select all

showif n == 3:
        text "Three" size 100 at cd_transform
Well that example doesn't fit my use.

So yes, I do like to try things myself, try to understand the code I find on the internet before asking and now I'm stuck, even though I'm sure it's a very simple thing to do. Any help?

Thanks.
Last edited by GMHLee on Sat Sep 03, 2022 2:54 am, edited 1 time in total.

User avatar
enaielei
Regular
Posts: 114
Joined: Fri Sep 17, 2021 2:09 am
Tumblr: enaielei
Deviantart: enaielei
Github: enaielei
Skype: enaielei
Soundcloud: enaielei
itch: enaielei
Discord: enaielei#7487
Contact:

Re: deactivating screen button...

#2 Post by enaielei » Wed Aug 31, 2022 1:06 pm

Code: Select all

screen select_girl:
    $select_girl_active = True
Never modify global variables inside a screen using $ or python:. Screen is a live display the re-runs its code multiple times to update the display.
In your label, you can just set the variable to True before the "call screen line" to achieve what you want.
You can also use on statement in screens. But afaik this only works for shown screens, using "show screen" instead of "call screen".

Code: Select all

screen select_girl():
  on "show" action SetVariable("select_girl_active", True)
Timers would also work for both called and shown screens. Just set repeat to False.

Code: Select all

screen select_girl():
  timer 0.01 action SetVariable("select_girl_active", True)

GMHLee
Newbie
Posts: 16
Joined: Thu Aug 25, 2022 7:00 am
Contact:

Re: deactivating screen button...

#3 Post by GMHLee » Wed Aug 31, 2022 1:24 pm

enaielei wrote:
Wed Aug 31, 2022 1:06 pm
Never modify global variables inside a screen using $ or python:. Screen is a live display the re-runs its code multiple times to update the display.
I see, I see, that at least certainly helps narrow down things to test out for now and in future. Much appreciated.
I'll try out the other suggestions and see how it goes, thanks.

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

Re: deactivating screen button...

#4 Post by Imperf3kt » Wed Aug 31, 2022 6:50 pm

Whenever this situation arises, I simply use if renpy.get_screen("screen name") and make the button insensitive if the screen is showing.

Don't know how proper it is, but works for me.
Remember
https://twitter.com/daisyowl/status/841 ... 0dzZQ&s=19
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

Post Reply

Who is online

Users browsing this forum: Google [Bot]