Character line displayed inside of a screen?

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.
Message
Author
UselessCoder
Regular
Posts: 96
Joined: Sun Jan 24, 2016 6:51 am
Projects: undisclosed...
Contact:

Character line displayed inside of a screen?

#1 Post by UselessCoder »

Hi guys,

Is there a way other than using vbox to have an imagebutton displaying a character's line as an action?

Thanks for any hint you might give me...

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Character line displayed inside of a screen?

#2 Post by namastaii »

What do you mean other than using a vbox? I'm a little confused by your question

UselessCoder
Regular
Posts: 96
Joined: Sun Jan 24, 2016 6:51 am
Projects: undisclosed...
Contact:

Re: Character line displayed inside of a screen?

#3 Post by UselessCoder »

namastaii wrote:What do you mean other than using a vbox? I'm a little confused by your question
Hi Namastaii (it rhymes, too! lol )

Well, what I meant is -and according to renpy docs- whenever you want to display text through the use of a screen, you use like

Code: Select all

screen display text

    add image_of_your_choice
    
    hbox:
        spacing 10 xpos 1170 ypos 20        
        text "display text"
but what I wonder is, can you have an imagebutton performing such action?

like:

Code: Select all

imagebutton idle "work_idle.png" hover "work_hover.png" xpos 0 ypos 0 focus_mask True action ShowText(m "I don't wanna work today!")
*Please note that either the action "ShowText" and the following format are both reflecting what I wish I could do with renpy. lol

Thanks!

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Character line displayed inside of a screen?

#4 Post by namastaii »

If you want the button to be of an image, you'll use imagebutton. If you just want text but you want a background to the text, you'll use textbutton and style the textbutton. You can, hovever, make the imagebutton have text on it when you create the image (in an art program) in the first place and just use imagebutton and you wouldn't need additional text.

Code: Select all

textbutton "display text"  style "my_button"
And I don't know if you know how styles work but it's pretty easy information to find for the most part.
Something like this that you could put in your options or anywhere with an init of some sort:

Code: Select all

style.my_button.background = "image.png"
style.my_button.hover_background = "image.png"
style.my_button_text.font = "font.ttf"
style.my_button_text.color = "696969"
style.my_button_text.hover_color = "ffffff"
There are many more attributes you can give the styles too. I'm used to the format I just showed you but I believe this way is more recent: https://www.renpy.org/doc/html/style_properties.html

Or imagebutton

Code: Select all

imagebutton:
  idle "image.png"
  hover "image.png"
*rereading your question I'm not sure I actually answered your question lool

Do you mean to push a button that brings up some text? pushing a button that when you push it, it brings up "I don't want to work today"?

If that's the case, you could either have the imagebutton bring up a new screen that has the text on it or you can have the button start a label in which the character says "i dont want to work today" in the dialogue or you can have a conditional within the screen to show the text in the same screen once you press the imagebutton.

If you want examples of any of those let me know. If I'm not even close to what you're wanting, let me know lol

UselessCoder
Regular
Posts: 96
Joined: Sun Jan 24, 2016 6:51 am
Projects: undisclosed...
Contact:

Re: Character line displayed inside of a screen?

#5 Post by UselessCoder »

Actually you don't, but that's surely me not being able to explain properly... :(

I just want a Character to say something once an imagebutton is clicked...As of now, I can only jump to a label where the character says that line but that's not what I want because:

1-it forces me to "rebuild" the screen piece by piece as a scene for the label;
2-I don't know how to make the label "dinamically" jump back to whichever label the screen was opened from...*

*that screen can be opened anytime anywhere during the game...

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Character line displayed inside of a screen?

#6 Post by namastaii »

ah...hmm

That does complicate things I guess if the screen can be called at any time. It'd be easy if they could only open this screen if they were at home or something. Then you'd just jump back to the same label every time. This is an interesting question because I've never tried this.

It'd be easy if your "i dont want to work" label could jump to the same label every time it's used.

UselessCoder
Regular
Posts: 96
Joined: Sun Jan 24, 2016 6:51 am
Projects: undisclosed...
Contact:

Re: Character line displayed inside of a screen?

#7 Post by UselessCoder »

namastaii wrote:ah...hmm

It'd be easy if your "i dont want to work" label could jump to the same label every time it's used.
Yeah...I had that...And like you said, it was way easier to achieve. But then I realized it felt unrealistic to feature an inventory that has that one ("work")option available from home only...Even tho "home" is the returning label after every finished shift and that makes sense.
The problem is that message has to popup every time the player tries to work more than once per day...Then it would make no sense to jump back home every time the character says "I've worked already today"...lol

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Character line displayed inside of a screen?

#8 Post by namastaii »

The only thing I can think of is displaying text in the middle of the screen saying "Bob doesn't want to work today." because I'm not sure if ren'py is capable of interrupting the current dialogue and then returning as usual. I could be wrong but i don't think I've seen it done

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Character line displayed inside of a screen?

#9 Post by namastaii »

Do you already have that set up? The variable in which it determines if the character has already worked in that day?

you could just have a pop up that says "You've already worked today!"

That is what I would do.

UselessCoder
Regular
Posts: 96
Joined: Sun Jan 24, 2016 6:51 am
Projects: undisclosed...
Contact:

Re: Character line displayed inside of a screen?

#10 Post by UselessCoder »

namastaii wrote:Do you already have that set up? The variable in which it determines if the character has already worked in that day?

you could just have a pop up that says "You've already worked today!"

That is what I would do.
Yup. That's how I structured it :)

In the beginning the imagebutton action jumped to a label that triggered/verified some flags.

it basically pointed to label work_start:

Code: Select all

label work_start:
   
    if namastaii_worked:
        n "I've had my share of work for today already..."
        jump namastaii_apt
it then checks which working rank you have and points you to the specific working category:

Code: Select all

    if persistent.stats ["CAR"]<10:
        jump rookie_jobs
    elif persistent.stats ["CAR"]>9 and persistent.stats ["CAR"]<20:
        jump intermediate_jobs
    elif persistent.stats ["CAR"]>19 and persistent.stats ["CAR"]<30:
        jump advanced_jobs         
Let's say you're a rookie.

Code: Select all

label rookie_jobs:
    $ namastaii_worked = True
    $ days_worked +=1
    $ rookie_job = renpy.random.randint (1,3)
    if  rookie_job == 1:
        "You solved the case of the undisplayable text!"
        $mod_money (25)
        $persistent.stats ["CAR"]+=1        
        if daytime:
            $ daytime = False
            jump namastaii_apt
        else:
            jump sleep
So it triggered the "namastaii_worked" flag, added money, and also checked if you started working during daytime or nightime so to leave you the night available to perform more actions or to send you straight to bed if you started working at night.
label namastaii_apt, of course, reverts $daytime back to true and $ namastaii_worked back to false at the beginning of every day.

But still, I wouldn't know how to make that message pop with the screen as a background lol

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Character line displayed inside of a screen?

#11 Post by namastaii »

Do you also have the variable reset to false once a new day begins? (namastaii_worked)

See, the message popping up is easy. There are a few ways you can do it. Is this button (the work button) always on the screen? You can add this task to that screen. I'm just going to make up a quick example off the top of my head of how I would do this.

Code: Select all

screen work_button():
    
    if namastaii_worked:
        textbutton "Go To Work" action Show("already_worked")
    else:
        textbutton "Go To Work" action Jump("at_work")
        
screen already_worked():
    
    frame:
        vbox:
            text "You already worked today!"
            textbutton "Okay" action Hide("already_worked")

UselessCoder
Regular
Posts: 96
Joined: Sun Jan 24, 2016 6:51 am
Projects: undisclosed...
Contact:

Re: Character line displayed inside of a screen?

#12 Post by UselessCoder »

Thanks namastaii!

that's definitely the closest thing to what I had in mind, even tho I'd rather try to find a way to have the Character saying that instead of having a popup...Or maybe trying to style that message of yours in the way of making it look like a "say" window, I dunno...

PS
and yes, there is a day_start label resetting that flag back to false (I told you in the previous post already! :P )

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Character line displayed inside of a screen?

#13 Post by namastaii »

I was thinking that too. You could always try to IMITATE a say statement. It might end up being an awkward task. If you made the text look exactly the same way (same font, same size) you could just take off that frame, and position the text down over where the textbox would be but the problem with that is needing to make sure there is no text in the textbox when that happens (or making a mock textbox for this message and overlaying the original textbox) and also figuring out how to make the screen go away without clicking a specific button, maybe just turning the mock textbox into a giant imagebutton. I mean, it could be possible with a lot of imagination haha if you really REALLY want it.

edit: just remembered, you wouldn't need to make a new textbox for a mock one. you would just use window.

Code: Select all

screen already_worked:
    window:
        vbox:
            text "name"
            text "You already worked today!" 
or something like that. but then i dont think you can turn it into a button. Idk it's just complicated lol

UselessCoder
Regular
Posts: 96
Joined: Sun Jan 24, 2016 6:51 am
Projects: undisclosed...
Contact:

Re: Character line displayed inside of a screen?

#14 Post by UselessCoder »

namastaii wrote: I mean, it could be possible with a lot of imagination haha if you really REALLY want it.
Yup...lol
And having side images for any of my characters doesn't make it any easier...I mean I could also try to make a whole new screen for that. I could put together an image by merging the textbox, the text "already worked etc etc", the who label and the side image, adding it to a screen and overlapping it on the other screen through the zorder :D
that might be a solution...A crappy one, but still! lol
Last edited by UselessCoder on Mon Jul 04, 2016 2:49 pm, edited 1 time in total.

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Character line displayed inside of a screen?

#15 Post by namastaii »

Yeah. I mean go for it if you desire XD

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]