Display character text when clicking on an image 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
renpyhelp
Regular
Posts: 71
Joined: Tue Feb 27, 2018 2:01 am
Contact:

Display character text when clicking on an image button?

#1 Post by renpyhelp »

Currently I have an image button on a screen that opens up an interactive phone
[Show("girls_phone")]

I then have another image button that when clicked, I need it to displays a characters text. example:

Code: Select all

p "I'm talking right now."
Currently, any way I get it to show text, it removes the two screens displayed. I just want it to display text and remove it once it's clicked through.
I also use module True on the "girls_phone" screen (as I don't want imagebuttons on the original screen to be clicked on), and found that I can't click through the text.

Is there any way to get around this?

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Display character text when clicking on an image button?

#2 Post by kivik »

Can you share the code of the relevant parts for us to have a look at?

Screens is one of the ren'py things I'm still trying to get my head around, and when I think I know it, something else throws me off. Perhaps seeing your code could help though as what you described sounds like it should work.

renpyhelp
Regular
Posts: 71
Joined: Tue Feb 27, 2018 2:01 am
Contact:

Re: Display character text when clicking on an image button?

#3 Post by renpyhelp »

Code: Select all


screen scene_girlstexts:
    modal True
    imagemap:
        ground "girlstexts_g"
        hover "phone_1_h"
        alpha False
       
        
        hotspot (659, 652, 72, 35) action [Hide("scene_girlstexts"), Show("scene_girlsphone")] activate_sound "sounds/se_click2.ogg"
        
    imagebutton:
        idle "girlsphone_pic1_g"
        hover "girlsphone_pic1_h"
        xpos 635 ypos 478
        action NullAction()
the action I just need to display the players thoughts through text and continue as it was.

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Display character text when clicking on an image button?

#4 Post by kivik »

Can I confirm that you're just adding an interactive element to a scene in your game, where you have to click on the image of the phone to load the text and phone etc.?

If so, I think you can use "call screen" instead of "show screen".

Call screen essentially pauses the game awaiting user input - which the fact that you're doing modal True implies is what you wanted. Then if the player clicks the hotspot, you want to call the scene_girlsphone screen as well instead of showing it - again awaiting user input to click on the imagebutton.

Once user input's happened, it'll return the game flow to your dialogues.

So your code would look something like this on the main script:

Code: Select all

...
call screen scene_girlstexts
"Dialogue goes here after player clicks on the imagebutton on the scene_girlsphone screen"
...

AFAIK you only really want to show screen in situations where a) you just want to display information, e.g. game HUD; b) you want the player to be able to click some buttons at any point in the game regardless of game flow.

This is the part I'm a bit confused about in general, so I could be mistaken. But if my interpretation of your scenario is right, you can just use call screen and not worry about the game flow.

renpyhelp
Regular
Posts: 71
Joined: Tue Feb 27, 2018 2:01 am
Contact:

Re: Display character text when clicking on an image button?

#5 Post by renpyhelp »

Still not sure how to show text within a screen.

Code: Select all

  
    imagebutton:
        idle "girlsphone_g"
        hover "girlsphone_h"
        xpos 635 ypos 478
        action Call ("test_test")
        
label test_test:
     p "This is a test."
        
If I put a Call to the action, it removes the screen that was shown, including all the imagebuttons that were on the screen. Just want the screen to stay as is with the text showing up and once clicked, removes the text and nothing changes.

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Display character text when clicking on an image button?

#6 Post by kivik »

Oh sorry I misunderstood you. I thought you wanted the screen to go away after clicking because you had Hide("scene_girlstexts") in the code which will hide the first screen with the imagemap.

I think the first screen will stay if you get rid of the Hide statement (just make sure you hide the screen at some point).

You also probably need to get rid of the modal = True statement if you have it on your screen scene_girlsphone - that stops player from being able to click through the text in your original example. There lies our dilemma though that you don't want your player to be able to click the first screen, but player to be able to click through the dialogue...

What I'd suggest is you let the first screen (with the imagemap) be hidden when the second screen (scene_girlsphone) shows up. Then you don't need modal = True to prevent unwanted clicking of first screen, but allows your player to advance the dialogue.

I hope this makes more sense, but if I'm still getting the wrong end of the stick, please give screenshots (crude ones are fine) to show step by step what's supposed to happen and I may understand the intended flow better!

Sorry if I'm confused.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Majestic-12 [Bot]