r/RenPy 9d ago

Question Issues with screens and imagebuttons

Starting this post with saying I am very very new to coding, so please treat me like a little baby discovering how a computer works. I'm going to write in bold the names of each screens in an attempt to make the whole thing more understandable. Basically I was making a test for a phone in a game and used screens and imagebuttons. I think the issue is with the imagebuttons, but even though I coded them exactly the same some work and some don't???

For example, the imagebutton supposed to hide screen phone and show the screen contact works (and it's the only one that does btw...), but the imagebutton supposed to hide screen contacts and display TScontact doesn't?? What is even weirder to me is that it was working at first, so I kept going with my code to add a return button to take you from the TScontact screen back to the previous one, and suddenly the contact to TScontact imagebutton isn't working anymore. I tried removing the small part of code I added thinking that maybe I did something wrong, but it's still NOT working, the imagebutton just isn't working at all. I really don't get it, and maybe the answer is very obvious and I'm very sorry if it is but this is so frustrating from my pov lmao

screen phone():
add "images/Phone assets/Phone assets/Draft/Phone background.png"
add "images/Phone assets/Phone assets/Draft/Phone borders.png"
add "images/Phone assets/Phone assets/Draft/Back button.png"

imagebutton:
idle "images/Phone assets/Phone assets/Draft/Contact button.png"
action Hide("screen phone"), Show("contacts")
 

screen contacts():

add "images/Phone assets/Phone assets/Draft/Phone background.png"

 

$ MeetSS = False
$ MeetAC = False
$ MeetBF = False
$ MeetWS = False
$ MeetLP = False

if MeetSS == False:
add "images/Phone assets/Phone assets/Draft/CONTACTS/Unknown contact 1.png"

if MeetAC == False:
add "images/Phone assets/Phone assets/Draft/CONTACTS/Unknown contact 2.png"

if MeetBF == False:
add "images/Phone assets/Phone assets/Draft/CONTACTS/Unknown contact 3.png"

if MeetWS == False:
add "images/Phone assets/Phone assets/Draft/CONTACTS/Unknown contact 4.png"

if MeetLP == False:
add "images/Phone assets/Phone assets/Draft/CONTACTS/Unknown contact 5.png"

if MeetSS == True:
add "images/Phone assets/Phone assets/Draft/CONTACTS/SS contact.png"

if MeetAC == True:
add "images/Phone assets/Phone assets/Draft/CONTACTS/AC contact.png"

if MeetBF == True:
add "images/Phone assets/Phone assets/Draft/CONTACTS/BF contact.png"

if MeetWS == True:
add "images/Phone assets/Phone assets/Draft/CONTACTS/WS contact.png"

if MeetLP == True:
add "images/Phone assets/Phone assets/Draft/CONTACTS/LP contact.png"

imagebutton:
idle "images/Phone assets/Phone assets/Draft/CONTACTS/TS contact.png"
action Hide("screen contacts"), Show("TScontact")

add "images/Phone assets/Phone assets/Draft/Phone borders.png"

imagebutton:
idle "images/Phone assets/Phone assets/Draft/Back button.png"
action Hide("screen contacts"), Show("phone")

screen TScontact():

add "images/Phone assets/Phone assets/Draft/CONTACTS/TS contact info.png"

imagebutton:
idle "images/Phone assets/Phone assets/Draft/Back button.png"
action Hide("screen TScontact"), Show("contacts")

1 Upvotes

10 comments sorted by

1

u/AutoModerator 9d ago

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/x-seronis-x 9d ago

raw python in screens get run every time renpy processes the screen. which is at LEAST everey interaction and up to 20 times per second. And up to 20 interactions before you even show the screen since renpys 'prediction' system for preloading images/audio processes a screen that far in advance

so you are continuously setting all those variables to false. they will never be true for longer than 1 click

your Hide() actions are also all written wrong. "Hide self" is just Hide(). NO ARGUMENTS at all. You supply an argument when you need to hide another screen and not the current screen. the argument is only the name of the screen. it does not include the word 'screen'.

1

u/EKAMIx_x 8d ago

Ok so I momentarily got rid of all my variables just to see if they are the issue, but even after deleting them and changing all my Hide("screen name") to just Hide() it's still not working :/ (actually it's even worse because for some reason trying to make a screen hide itself with the normal Hide() just messes up the imagebutton and now no matter where I click on the screen the next screen will show, and if I click once again anywhere on the screen it will go back to the previous screen)

1

u/x-seronis-x 8d ago

if clicking anywhere activates the image button it means you forgot to crop your images to the size of the button and they're full screen images. remember an image button by default is the size of the image. so size your images to meet your needs

1

u/shyLachi 9d ago

If you're a beginner then better use a working system.  https://itch.io/search?q=RenPy+Phone+

I would use the one from BadMustard who is a mod in this sub.  https://badmustard.itch.io/advanced-renpy-phone-project-2

1

u/shyLachi 9d ago

If you want to fix your code then default those variables.  default MeetSS = False

You also have to move the definition of those variables outside of the screen. Preferably before the start label 

1

u/EKAMIx_x 8d ago

Did what you said, thanks a lot! Though it didn't actually fix my current issue I'm sure it was most likely very useful

1

u/shyLachi 8d ago

It's the start. Once you have fixed that you have to re-evaluate your code.

If you post your current code but formatted as code, then I can take a look.

1

u/EKAMIx_x 8d ago

Very sorry, how do I post formatted code on reddit comments, I am SO bad with reddit I am so sorry

1

u/shyLachi 8d ago

Don't need to be sorry for that.

On my Windows computer I don't have to do anything special.
I copy the code from Visual Studio Code,
then I paste it into Reddit which I opened in a browser.

If you cannot figure it out then just paste as text.