Chatroom-like layout in Ren'py?

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
madocallie
Regular
Posts: 44
Joined: Tue May 14, 2013 1:57 am
Completed: Bad Faith (DEMO), When We First Met, Party Favors
Projects: Bad Faith (Full Release)
itch: madocallie
Location: UK
Discord: madocallie#2937
Contact:

Chatroom-like layout in Ren'py?

#1 Post by madocallie » Thu Nov 02, 2017 9:48 am

Hey, I haven't been on here in quite a while, but I've been planning to make another visual novel for a game jam!

One thing I'd like it to incorporate is chatroom-like dialogue in certain scenes.

Sorta like this: https://img.itch.zone/aW1hZ2UvMTQzODk ... wzN.png (from Brianna Lei's fantastic game Butterfly Soup!)

How should I go about coding it? I have a feeling I'd need to heavily edit NVL code or something, but I'm not quite sure...
Image

User avatar
Kia
Eileen-Class Veteran
Posts: 1011
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Chatroom-like layout in Ren'py?

#2 Post by Kia » Thu Nov 02, 2017 3:26 pm

it seems NVL is the right choice, however, it shouldn't be that hard to make it look like chat, just add a frame around each "text d.what:" and it should look like the chat you want

User avatar
madocallie
Regular
Posts: 44
Joined: Tue May 14, 2013 1:57 am
Completed: Bad Faith (DEMO), When We First Met, Party Favors
Projects: Bad Faith (Full Release)
itch: madocallie
Location: UK
Discord: madocallie#2937
Contact:

Re: Chatroom-like layout in Ren'py?

#3 Post by madocallie » Thu Nov 02, 2017 4:27 pm

Kia wrote:
Thu Nov 02, 2017 3:26 pm
it seems NVL is the right choice, however, it shouldn't be that hard to make it look like chat, just add a frame around each "text d.what:" and it should look like the chat you want
cool! that's good to know!

next question:
how would i go about adding icons/images like in the example above?
Image

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

Re: Chatroom-like layout in Ren'py?

#4 Post by Imperf3kt » Thu Nov 02, 2017 4:31 pm

You can insert images in text using the {image=""} function
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

User avatar
madocallie
Regular
Posts: 44
Joined: Tue May 14, 2013 1:57 am
Completed: Bad Faith (DEMO), When We First Met, Party Favors
Projects: Bad Faith (Full Release)
itch: madocallie
Location: UK
Discord: madocallie#2937
Contact:

Re: Chatroom-like layout in Ren'py?

#5 Post by madocallie » Thu Nov 02, 2017 4:49 pm

Imperf3kt wrote:
Thu Nov 02, 2017 4:31 pm
You can insert images in text using the {image=""} function
i know that can be done, but since a good portion of my game is going to take place in these chatrooms, is there a way to assign an image to a character instead of repeating the image over and over?
Kia wrote:
Thu Nov 02, 2017 3:26 pm
it seems NVL is the right choice, however, it shouldn't be that hard to make it look like chat, just add a frame around each "text d.what:" and it should look like the chat you want
also just a quick question: where do i find the "text d. what:" parts of the code..?
Image

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

Re: Chatroom-like layout in Ren'py?

#6 Post by Imperf3kt » Thu Nov 02, 2017 5:57 pm

You want to emulate emoticons, right?
All I can think of is {image="smiley.png"}
Or

Code: Select all

image smiley:
    "smiley.png"
    pause 0.5
    "smiley2.png"
    pause 0.5
    repeat


{image="smiley"}
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

User avatar
madocallie
Regular
Posts: 44
Joined: Tue May 14, 2013 1:57 am
Completed: Bad Faith (DEMO), When We First Met, Party Favors
Projects: Bad Faith (Full Release)
itch: madocallie
Location: UK
Discord: madocallie#2937
Contact:

Re: Chatroom-like layout in Ren'py?

#7 Post by madocallie » Thu Nov 02, 2017 6:15 pm

Imperf3kt wrote:
Thu Nov 02, 2017 5:57 pm
You want to emulate emoticons, right?
All I can think of is {image="smiley.png"}
Or

Code: Select all

image smiley:
    "smiley.png"
    pause 0.5
    "smiley2.png"
    pause 0.5
    repeat


{image="smiley"}
[/quote]
i actually wanted to emulate user icons, but this is helpful too!
Image

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Chatroom-like layout in Ren'py?

#8 Post by Divona » Thu Nov 02, 2017 10:51 pm

madocallie wrote:
Thu Nov 02, 2017 4:49 pm
also just a quick question: where do i find the "text d. what:" parts of the code..?
That will be under "screen nvl_dialogue" in "screens.rpy" file.
Completed:
Image

User avatar
madocallie
Regular
Posts: 44
Joined: Tue May 14, 2013 1:57 am
Completed: Bad Faith (DEMO), When We First Met, Party Favors
Projects: Bad Faith (Full Release)
itch: madocallie
Location: UK
Discord: madocallie#2937
Contact:

Re: Chatroom-like layout in Ren'py?

#9 Post by madocallie » Fri Nov 03, 2017 7:50 am

Divona wrote:
Thu Nov 02, 2017 10:51 pm
madocallie wrote:
Thu Nov 02, 2017 4:49 pm
also just a quick question: where do i find the "text d. what:" parts of the code..?
That will be under "screen nvl_dialogue" in "screens.rpy" file.
excellent! thanks so much!

just to ask again, but is there also a way of incorporating user icons into the chat too..? (like in the example above?)
Image

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Chatroom-like layout in Ren'py?

#10 Post by Divona » Fri Nov 03, 2017 8:57 am

Perhaps you could assign an image to Character() and use that to add the image in front of the NVL text?

Code: Select all

define d = Character("Divona", kind=nvl, icon="divona_avatar.png")
Then in "screens.rpy" under "screen nvl_dialogue":

Code: Select all

screen nvl_dialogue(dialogue):

    for d in dialogue:

        window:
            id d.window_id

            fixed:
                yfit gui.nvl_height is None

                if "icon" in d.who_args:
                    add d.who_args["icon"] xalign 0.1

                if d.who is not None:

                    text d.who:
                        id d.who_id

                text d.what:
                    id d.what_id
Not a pretty as of now, but you get the idea.
Completed:
Image

User avatar
madocallie
Regular
Posts: 44
Joined: Tue May 14, 2013 1:57 am
Completed: Bad Faith (DEMO), When We First Met, Party Favors
Projects: Bad Faith (Full Release)
itch: madocallie
Location: UK
Discord: madocallie#2937
Contact:

Re: Chatroom-like layout in Ren'py?

#11 Post by madocallie » Fri Nov 03, 2017 10:06 am

Divona wrote:
Fri Nov 03, 2017 8:57 am
Perhaps you could assign an image to Character() and use that to add the image in front of the NVL text?

Code: Select all

define d = Character("Divona", kind=nvl, icon="divona_avatar.png")
Then in "screens.rpy" under "screen nvl_dialogue":

Code: Select all

screen nvl_dialogue(dialogue):

    for d in dialogue:

        window:
            id d.window_id

            fixed:
                yfit gui.nvl_height is None

                if "icon" in d.who_args:
                    add d.who_args["icon"] xalign 0.1

                if d.who is not None:

                    text d.who:
                        id d.who_id

                text d.what:
                    id d.what_id
Not a pretty as of now, but you get the idea.
cool! i'm gonna test this out right now.

back to the frame question by the way, but how exactly would i go about adding one to the code? I've been trying various ways without much success...
Image

User avatar
Kia
Eileen-Class Veteran
Posts: 1011
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Chatroom-like layout in Ren'py?

#12 Post by Kia » Fri Nov 03, 2017 10:56 am

try:

Code: Select all

                frame:
                    text d.what:
                        id d.what_id
you might want to fiddle with the position and alignment to get it right though

User avatar
madocallie
Regular
Posts: 44
Joined: Tue May 14, 2013 1:57 am
Completed: Bad Faith (DEMO), When We First Met, Party Favors
Projects: Bad Faith (Full Release)
itch: madocallie
Location: UK
Discord: madocallie#2937
Contact:

Re: Chatroom-like layout in Ren'py?

#13 Post by madocallie » Fri Nov 03, 2017 2:01 pm

Kia wrote:
Fri Nov 03, 2017 10:56 am
try:

Code: Select all

                frame:
                    text d.what:
                        id d.what_id
you might want to fiddle with the position and alignment to get it right though
how would i go about customizing it? i also want to add custom textboxes specifically for these scenes...
Image

User avatar
Kia
Eileen-Class Veteran
Posts: 1011
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Chatroom-like layout in Ren'py?

#14 Post by Kia » Fri Nov 03, 2017 3:32 pm

madocallie wrote:
Fri Nov 03, 2017 2:01 pm
how would i go about customizing it? i also want to add custom textboxes specifically for these scenes...
here's a striped down nvl screen you can start with:

Code: Select all

screen nvl(dialogue, items=None):
    window:
        xsize 1000 xalign .5
        style "nvl_window"
        vbox:
            spacing 40
            use nvl_dialogue(dialogue)

        for i in items:
            textbutton i.caption:
                action i.action
                style "nvl_button"

    add SideImage() xalign 0.0 yalign 1.0

screen nvl_dialogue(dialogue):
    for d in dialogue:
        window:
            id d.window_id
            hbox:
                xsize 1000 xalign 1.0
                if d.who is not None:
                    frame:
                        xsize 300 background None
                        text d.who:
                            xalign 1.0
                            id d.who_id
                frame:
                    xalign 1.0 xsize 800 
                    text d.what:
                        align(.5,.5)
                        id d.what_id

define config.nvl_list_length = 10
you'll have to delete all of the styles for this screen and start styling every element from scratch. if you don't know how, you need to read through https://www.renpy.org/doc/html/style.html and https://www.renpy.org/doc/html/screens.html

User avatar
madocallie
Regular
Posts: 44
Joined: Tue May 14, 2013 1:57 am
Completed: Bad Faith (DEMO), When We First Met, Party Favors
Projects: Bad Faith (Full Release)
itch: madocallie
Location: UK
Discord: madocallie#2937
Contact:

Re: Chatroom-like layout in Ren'py?

#15 Post by madocallie » Fri Nov 03, 2017 3:43 pm

Kia wrote:
Fri Nov 03, 2017 3:32 pm
madocallie wrote:
Fri Nov 03, 2017 2:01 pm
how would i go about customizing it? i also want to add custom textboxes specifically for these scenes...
here's a striped down nvl screen you can start with:

Code: Select all

screen nvl(dialogue, items=None):
    window:
        xsize 1000 xalign .5
        style "nvl_window"
        vbox:
            spacing 40
            use nvl_dialogue(dialogue)

        for i in items:
            textbutton i.caption:
                action i.action
                style "nvl_button"

    add SideImage() xalign 0.0 yalign 1.0

screen nvl_dialogue(dialogue):
    for d in dialogue:
        window:
            id d.window_id
            hbox:
                xsize 1000 xalign 1.0
                if d.who is not None:
                    frame:
                        xsize 300 background None
                        text d.who:
                            xalign 1.0
                            id d.who_id
                frame:
                    xalign 1.0 xsize 800 
                    text d.what:
                        align(.5,.5)
                        id d.what_id

define config.nvl_list_length = 10
you'll have to delete all of the styles for this screen and start styling every element from scratch. if you don't know how, you need to read through https://www.renpy.org/doc/html/style.html and https://www.renpy.org/doc/html/screens.html
Thanks so much!
Image

Post Reply

Who is online

Users browsing this forum: Google [Bot]