Imagebutton crashing game when I attempt to click it

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
EriksBlue
Regular
Posts: 36
Joined: Tue Jul 19, 2011 3:56 pm
Projects: Torn Apart
Location: California
Contact:

Imagebutton crashing game when I attempt to click it

#1 Post by EriksBlue »

I am trying to implement a imagebutton into my game, i can launch the game and get to the screen but as soon as I go to click the image i get this code. Can anyone help?

Code: Select all

While running game code:
  File "game/chapter1.rpy", line 133, in script
    call screen drop_menu
  File "renpy/common/000statements.rpy", line 569, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
  File "renpy/common/00action_control.rpy", line 126, in __call__
    renpy.show_screen(self.screen, *self.args, **self.kwargs)
Exception: Screen displayTextScreen is not known. 
My code

Code: Select all

    
    call screen drop_menu
screen drop_menu:
    imagebutton:
        idle "Key_image.png"
        hover "Key_image.png"
        focus_mask True
        xpos 1 ypos 1
        action [Hide("displayTextScreen"), Jump("end")]

        hovered Show("displayTextScreen",
            displayText = "Keys")
        unhovered Hide("displayTextScreen")
label end:
I as well have set up ui.imagebutton in the script.rpy file

Code: Select all

python:
    ui.frame(xalign=1,yalign=1)
    ui.imagebutton("Key_image.png", "Key_image.png", clicked=ui.returns(1))
    ui.interact()

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2438
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Imagebutton crashing game when I attempt to click it

#2 Post by Ocelot »

It says, that there is no screen "displayTextScreen". How do you define it?

> ui.imagebutton
Those should not ever be used again. Mentions of legacy UI functions are even purged from latest documentation.
< < insert Rick Cook quote here > >

User avatar
EriksBlue
Regular
Posts: 36
Joined: Tue Jul 19, 2011 3:56 pm
Projects: Torn Apart
Location: California
Contact:

Re: Imagebutton crashing game when I attempt to click it

#3 Post by EriksBlue »

Ocelot wrote: Tue May 31, 2022 5:43 pm It says, that there is no screen "displayTextScreen". How do you define it?

> ui.imagebutton
Those should not ever be used again. Mentions of legacy UI functions are even purged from latest documentation.
I am unfamiliar on how I would go about defining the "displayTextScreen".

Apologies I am out of practice with renpy. Thank you for the heads up about ui.imagebutton i was digging through posts trying to fix a earlier issue and that was one recommendation.
Image

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2438
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Imagebutton crashing game when I attempt to click it

#4 Post by Ocelot »

What is the line

Code: Select all

hovered Show("displayTextScreen",
            displayText = "Keys")
supposed to do?
< < insert Rick Cook quote here > >

User avatar
EriksBlue
Regular
Posts: 36
Joined: Tue Jul 19, 2011 3:56 pm
Projects: Torn Apart
Location: California
Contact:

Re: Imagebutton crashing game when I attempt to click it

#5 Post by EriksBlue »

Ocelot wrote: Tue May 31, 2022 6:27 pm What is the line

Code: Select all

hovered Show("displayTextScreen",
            displayText = "Keys")
supposed to do?
Well its suppose to show the word keys when the mouse is hovering over the image.
Image

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Imagebutton crashing game when I attempt to click it

#6 Post by rayminator »

then you want to use tooltips not show
https://www.renpy.org/doc/html/screen_a ... l#tooltips

User avatar
m_from_space
Eileen-Class Veteran
Posts: 1034
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Imagebutton crashing game when I attempt to click it

#7 Post by m_from_space »

EriksBlue wrote: Tue May 31, 2022 6:22 pmI am unfamiliar on how I would go about defining the "displayTextScreen".
User rayminator points you to tooltips, but actually your solution should be work flawlessly, too.

Your error suggests that the screen "displayTextScreen" is not known. Maybe a typo?

Show us your code for the screen! It should at least look like this:

Code: Select all

screen displayTextScreen(displayText):
    text displayText

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

Re: Imagebutton crashing game when I attempt to click it

#8 Post by Imperf3kt »

Place your screen outside of any labels!

Code: Select all

screen drop_menu:
    imagebutton:
        idle "Key_image.png"
        hover "Key_image.png"
        focus_mask True
        xpos 1 ypos 1
        action [Hide("displayTextScreen"), Jump("end")]

        hovered Show("displayTextScreen",
            displayText = "Keys")
        unhovered Hide("displayTextScreen")


#Screens do not go inside labels. Do not define screens beyond this point.
label start:
    "Do not place any screens or other items after this line"
    call screen drop_menu

label end:
The game will find your screen, only if it is outside a label.

Also, I don't think the show action while hovered is what you want. As soon as the screen is shown, your button will be covered by the new screen, thus no longer hovered.


Just to be sure, can you check the screen exists.
In the Ren'Py launcher, click on "navigate script"
Image
Then go across to "screens" and confirm your screen is listed:
Image
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

Post Reply

Who is online

Users browsing this forum: No registered users