Ren'Py Hovered image button?

9thCrux

--Waifu maker--
Game Developer
Oct 22, 2017
844
3,232
do
Code:
call screen my_screen
instead of
Code:
show screen my_screen
- call transfers focus and wait for interaction
Thanks, it works...

I can use it to call my_screen from script.rpy but it doesn't let me use it inside a screen definition like:

screen room:
add "room.png"
imagebutton auto "room_%s.png" xpos 744 ypos 85 focus_mask True action Hide("room"), Call("inroom")

Is asking me for a label, it doesn't let me use a screen.

It seems to work fine if I call it from the script.rpy but I'm getting some weird behavior... I think I need to hide the hall before going to another screen.

Maybe if I define the screens and then make labels to handle the call...
Like a new label that would call the screen "room" and then use that new label inside the next screen definition...

Coding logic can be so tiring...
 

Studio Errilhl

Member
Game Developer
Oct 16, 2017
315
237
You should really read the docs for Renpy. First off, if you're using multiple actions, you need to put them in a list. So it would be
Code:
action [Hide('room'),Call('inroom')]
- second, Call() works from inside a screen, in an action, as long as you're using the latest version of Renpy. But that might have to do with the missing list.

Also, the screens you have defined... I would probably chose to use "scene" instead of "add" for the background images.
 

9thCrux

--Waifu maker--
Game Developer
Oct 22, 2017
844
3,232
You should really read the docs for Renpy. First off, if you're using multiple actions, you need to put them in a list. So it would be
Code:
action [Hide('room'),Call('inroom')]
- second, Call() works from inside a screen, in an action, as long as you're using the latest version of Renpy. But that might have to do with the missing list.

Also, the screens you have defined... I would probably chose to use "scene" instead of "add" for the background images.

XD

Using screens you have to use add... screens use their own little language if you read the documentation you will know that :eek:penedeyewink:

Is just about what you decide to use; scenes or screens, I guess is about personal preferences.

I wonder if you can actually use ' instead of " inside those [()] guess I would have to try...

Code:
screen my_screen:
    add "hall.png"
    imagebutton auto "halldoor1_%s.png" xpos 459 ypos 241 focus_mask True action Hide("my_screen"), Hide("room"), Hide("bath"), Hide("inroom"), Show("room")
    imagebutton auto "halldoor2_%s.png" xpos 783 ypos 231 focus_mask True action Hide("my_screen"), Hide("room"), Hide("bath"), Hide("inroom"), Show("bath")
    imagebutton auto "halldoor3_%s.png" xpos 971 ypos 83 focus_mask True action Hide("my_screen"), Hide("room"), Hide("bath"), Hide("inroom"), Show("inroom")
 

screen room:
    add "room.png"
    imagebutton auto "room_%s.png" xpos 744 ypos 85 focus_mask True action Hide("my_screen"), Hide("room"), Hide("Hall"), Hide("bath"), Hide("my_screen"), Show("inroom")
 
screen bath:
    add "bath.png"
    imagebutton auto "bathd_%s.png" xpos 1215 ypos 175 focus_mask True action Hide("bath"), Hide("room"), Hide("inroom"), Hide("my_screen"), Show("my_screen")
 
screen inroom:
    add "roomin.png"
    imagebutton auto "roomind_%s.png" xpos 935 ypos 72 focus_mask True action Hide("inroom"), Hide("room"), Hide("bath"), Hide("my_screen"), Show("my_screen")
This is working for me now tho.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
11,036
16,359
So it would be
Code:
action [Hide('room'),Call('inroom')]
- second, Call() works from inside a screen, in an action, as long as you're using the latest version of Renpy.
While it works, I really don't recommend to use the screen action Call unless you're a good coder. There's already too many games using the statement Call which fail to correctly return from the called label, so if you go :
Code:
  [...]
   call someScreen
  [...]

screen someScreen:
    [...]
       action Call( "someLabel" )
you'll have a hard time keeping the game flow under control.

The best option is to rely on the Return screen action :
Code:
label:
    [...]
    while True:
        call myScreen
        if _return == "door":
           jump theDoor
        elif _return == "computer":
           jump computer

screen myScreen:
    [...]
    imagebutton [...]:
        action Return( "door" )
If there's only one thing clickable, by example if you want the player to manually open the door, you don't even need to test the return value, nor having one :
Code:
label:
    [...]
    call myScreen
    "I've waited patiently"

screen myScreen:
    [...]
    imagebutton [...]:
        action Return( "" )
Side note: Few years ago, Tom said that he will never ever implement a "Call" screen action... There's hope in the future :D


Using screens you have to use add... screens use their own little language if you read the documentation you will know that :eek:penedeyewink:
I think he thought it this way :
Code:
   scene myBackground
   call screen myGenericButtons( "door" )

screen myGenericButtons( which ):
   if which == "door":
      imagebutton [...]:
         action Return( "" )
   elif which == "computer":
     imagebutton [...]:
         action Return( "" )