telegram messenger (4 version)

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Message
Author
User avatar
sDextra
Regular
Posts: 40
Joined: Fri Oct 12, 2018 2:06 am
Organization: Event Horizon Games
Github: sDextra
Location: Kazakhstan
Contact:

Re: telegram messenger (2 version)

#76 Post by sDextra »

fauxbius wrote: Mon Jun 24, 2019 12:22 pm
sDextra wrote: Mon Jun 24, 2019 10:38 am
If I understand you correctly, you can try using this function:

Code: Select all

$ freeze() 
# your actions
$ unfreeze()
I actually ended up doing the below using the del_last_msg, as the freeze didn't work, it wouldn't unfreeze after taking a name, or wouldn't let me inout anything. The problem is that you type the name, it gets sent and displayed as a message. You can't use the input and just display the last line in this code without using del_last_msg to clear the previous one first.

Code: Select all

    $ msg(None, name_input=True)    
    if name=="Jack":
            $ msg ("Yeah, this is Jack")
    else:
        $ del_last_msg()
        $ msg ("No, it\'s [name]")
Not ("No, it\'s [name]") but ("No, it\'s %s"%(name))
if you want to input a name outside the message bubble:

Code: Select all

    $ name = renpy.input(u"What's your name?", length=25).title()
    if name=="Jack":
        $ msg ("Yeah, this is Jack")
    else:
        $ msg ("No, it\'s %s"%(name))

fauxbius
Newbie
Posts: 5
Joined: Fri Jun 14, 2019 5:56 pm
Contact:

Re: telegram messenger (2 version)

#77 Post by fauxbius »

sDextra wrote: Mon Jun 24, 2019 2:43 pm
Not ("No, it\'s [name]") but ("No, it\'s %s"%(name))
if you want to input a name outside the message bubble:

Code: Select all

    $ name = renpy.input(u"What's your name?", length=25).title()
    if name=="Jack":
        $ msg ("Yeah, this is Jack")
    else:
        $ msg ("No, it\'s %s"%(name))

I was using the below code and trying to get the input using the messenger system.

Code: Select all

    $ msg ("Hey, is this Jack?", who=1, status='online')

    $ msg (None, choices={0:{'jump':'dialogue2', 'name':"Yeah, this is Jack"}, 1:{'jump':'name_is_enteredbyuser', 'name':"No, it\'s"}})


label name_is_enteredbyuser:
    $ show_tooltip()
    $ msg(None, name_input=True)
    jump dialogue2

label dialogue2:

    if name=="Jack":
            $ msg ("Yeah, this is Jack")
    else:
        $ del_last_msg()
        $ msg ("No, it\'s [name]")
It isn't super important as I have the del_last_msg workaround.

Also having an issue with an image that is 500 x 516 pixels displaying squashed. Included a screenshot and the original.
Image
Image

I realllllllyyy appreciate the help, this script is great.

User avatar
sDextra
Regular
Posts: 40
Joined: Fri Oct 12, 2018 2:06 am
Organization: Event Horizon Games
Github: sDextra
Location: Kazakhstan
Contact:

Re: telegram messenger (2 version)

#78 Post by sDextra »

fauxbius wrote: Mon Jun 24, 2019 5:43 pm
Also having an issue with an image that is 500 x 516 pixels displaying squashed. Included a screenshot and the original.
Image
Image
This is because the standard aspect ratio is 16:9
Now I added setting a specific picture size (x,y)
changes in messenger.rpy on GitHub

Just set the picture size, in your case is 371 (y)
*500/516=0.968
*360/0,968=371
*360 is default x size

Code: Select all

$ msg(None, pic="coffee", pic_y=371)
Image
Attachments
messenger.rpy
(23.27 KiB) Downloaded 58 times

fauxbius
Newbie
Posts: 5
Joined: Fri Jun 14, 2019 5:56 pm
Contact:

Re: telegram messenger (2 version)

#79 Post by fauxbius »

sDextra wrote: Mon Jun 24, 2019 6:12 pm I just basically fixed and updated code on demand because I am incredible
Thanks!

fauxbius
Newbie
Posts: 5
Joined: Fri Jun 14, 2019 5:56 pm
Contact:

Re: telegram messenger (2 version)

#80 Post by fauxbius »

Quick note that with testing, I can't use images over 580px height. Anything over displays skewed even if I use the pic_y argument properly.

Would be amazing to get larger images supported, I'm probably gonna use this code heavily in a game. Trying to work now on implementing a calling system and some sort of menu maybe. I am completely new to renpy and almost completely new to python. Yay!

Couple of things with the code I'm find are that:

When I go to normal textbox to a msg choice, I have to scroll down to see that choice when the scroll bar is present. i.e. The msg choice code at the bottom shows up in the messenger, but you have to scroll down to see it.

Code: Select all

    $ msg ("Hey, [name]. It's [b] from the Daily Grind", who=1, status='online')
    $ show_tooltip(n=2)
    $ msg (None, who=1, pic="goth_selfie", pic_y=464)
    $ msg ("Remember me?", who=1)

    u "It's the coffee shop girl!"
    u "Damn, she's keen..."
    window hide

    $ msg (None, choices={0:{'jump':'remember_belle', 'name':"Of course!"}, 1:{'jump':'dont_remember_belle', 'name':"Uh, no?"}})

User avatar
sDextra
Regular
Posts: 40
Joined: Fri Oct 12, 2018 2:06 am
Organization: Event Horizon Games
Github: sDextra
Location: Kazakhstan
Contact:

Re: telegram messenger (2 version)

#81 Post by sDextra »

fauxbius wrote: Wed Jun 26, 2019 2:51 pm Quick note that with testing, I can't use images over 580px height. Anything over displays skewed even if I use the pic_y argument properly.

Would be amazing to get larger images supported, I'm probably gonna use this code heavily in a game. Trying to work now on implementing a calling system and some sort of menu maybe. I am completely new to renpy and almost completely new to python. Yay!
This is because the fixed maximum size for the message bubble is set. Just remove 'xmaximum 580' from the messenger.rpy
fauxbius wrote: Wed Jun 26, 2019 2:51 pm When I go to normal textbox to a msg choice, I have to scroll down to see that choice when the scroll bar is present. i.e. The msg choice code at the bottom shows up in the messenger, but you have to scroll down to see it.
I found only one way to fix it. Need to add the function "down()".

Code: Select all

# messenger.rpy
init python:
    ***
    def down():
        store.yadj.value = 9999*9999
        
***
screen messenger():
    ***
        ***
            for message in all_message:
                ***
                timer 0.001 action Function(down)
func down in messenger.rpy
p.s.: I do not really like this option, because it is a workaround. But I have not found another solution.

I hope this will help you.
Attachments
messenger.rpy
(23.34 KiB) Downloaded 48 times

Overdose
Newbie
Posts: 23
Joined: Sun May 27, 2018 12:30 am

Re: telegram messenger (2 version)

#82 Post by Overdose »

Hello! Sorry to bother, but I have a question ^^;

How do I change the font of the game? I know how to change the font of the menu, narration and dialogue etc, but how do I change the text message fonts?

Thank you! ^^

User avatar
sDextra
Regular
Posts: 40
Joined: Fri Oct 12, 2018 2:06 am
Organization: Event Horizon Games
Github: sDextra
Location: Kazakhstan
Contact:

Re: telegram messenger (2 version)

#83 Post by sDextra »

Overdose wrote: Fri Jul 05, 2019 7:47 pm Hello! Sorry to bother, but I have a question ^^;

How do I change the font of the game? I know how to change the font of the menu, narration and dialogue etc, but how do I change the text message fonts?

Thank you! ^^

Code: Select all

#images.rpy
init -1000 python:
    style_font = 'fonts/tahoma.ttf'
    style_font_monospace = 'fonts/hack.ttf'
'style_font' - this is the text message font.

Overdose
Newbie
Posts: 23
Joined: Sun May 27, 2018 12:30 am

Re: telegram messenger (2 version)

#84 Post by Overdose »

sDextra wrote: Fri Jul 05, 2019 11:50 pm
Overdose wrote: Fri Jul 05, 2019 7:47 pm Hello! Sorry to bother, but I have a question ^^;

How do I change the font of the game? I know how to change the font of the menu, narration and dialogue etc, but how do I change the text message fonts?

Thank you! ^^

Code: Select all

#images.rpy
init -1000 python:
    style_font = 'fonts/tahoma.ttf'
    style_font_monospace = 'fonts/hack.ttf'
'style_font' - this is the text message font.
oh!! Thank you!! ^^

Denys01
Newbie
Posts: 3
Joined: Fri Jul 12, 2019 12:43 pm
Contact:

Re: telegram messenger (2 version)

#85 Post by Denys01 »

Hello~!

I've tried changing the avatars for the characters in the group chat mig game but failed miserably in doing so... I thought of using a persistent but it's definitely not the best thing I could use. I also thought of using a condition switch but somehow I ended up with an error screen everytime... Could you please tell me how to change the avatars mid game?

Thanks a lot (:

User avatar
sDextra
Regular
Posts: 40
Joined: Fri Oct 12, 2018 2:06 am
Organization: Event Horizon Games
Github: sDextra
Location: Kazakhstan
Contact:

Re: telegram messenger (2 version)

#86 Post by sDextra »

Denys01 wrote: Fri Jul 12, 2019 12:53 pm Hello~!

I've tried changing the avatars for the characters in the group chat mig game but failed miserably in doing so... I thought of using a persistent but it's definitely not the best thing I could use. I also thought of using a condition switch but somehow I ended up with an error screen everytime... Could you please tell me how to change the avatars mid game?

Thanks a lot (:

Code: Select all

$ groupchat.add( Interlocutor(ID=1, name='Poe', color='#fff68f', avatar='messenger/groupchat/yourname.png') )
?

Denys01
Newbie
Posts: 3
Joined: Fri Jul 12, 2019 12:43 pm
Contact:

Re: telegram messenger (2 version)

#87 Post by Denys01 »

Ah yes sorry I wasn’t clear enough ! Changing their avatars is not a problem, what I mean is that I want to change the characters’ avatars several times at different points throughout the game. For example, I want character X to have image 1 as their avatar in chapter 1 but then change for image 2 in chapter 2.

In any case, thanks for taking the time to help ! (:

User avatar
sDextra
Regular
Posts: 40
Joined: Fri Oct 12, 2018 2:06 am
Organization: Event Horizon Games
Github: sDextra
Location: Kazakhstan
Contact:

Re: telegram messenger (2 version)

#88 Post by sDextra »

Denys01 wrote: Fri Jul 12, 2019 6:30 pm Ah yes sorry I wasn’t clear enough ! Changing their avatars is not a problem, what I mean is that I want to change the characters’ avatars several times at different points throughout the game. For example, I want character X to have image 1 as their avatar in chapter 1 but then change for image 2 in chapter 2.

In any case, thanks for taking the time to help ! (:
I added a couple of new functions:

Code: Select all

#messenger.rpy
    class Interlocutor():
        def __init__(self, ID=1, name='Name', color='#fff', avatar=False):
            self.id = ID
            self.name = name
            self.color = color
            self.avatar = avatar if avatar else 'messenger/groupchat/'+name.lower().replace(' ', '_')+'.png' 
        # new
        def set_avatar(self, new_avatar):
            self.avatar = new_avatar
        def set_name(self, new_name):
            self.name = new_name
Usage:

Code: Select all

$ groupchat.list[0].set_avatar('messenger/groupchat/yournewavatar.png')
*But in this case, the avatar will automatically change in old messages.
**If this does not suit you, create another character with this name, but a new avatar. It is a workaround.

Denys01
Newbie
Posts: 3
Joined: Fri Jul 12, 2019 12:43 pm
Contact:

Re: telegram messenger (2 version)

#89 Post by Denys01 »

sDextra wrote: Fri Jul 12, 2019 6:42 pm
Denys01 wrote: Fri Jul 12, 2019 6:30 pm Ah yes sorry I wasn’t clear enough ! Changing their avatars is not a problem, what I mean is that I want to change the characters’ avatars several times at different points throughout the game. For example, I want character X to have image 1 as their avatar in chapter 1 but then change for image 2 in chapter 2.

In any case, thanks for taking the time to help ! (:
I added a couple of new functions:

Code: Select all

#messenger.rpy
    class Interlocutor():
        def __init__(self, ID=1, name='Name', color='#fff', avatar=False):
            self.id = ID
            self.name = name
            self.color = color
            self.avatar = avatar if avatar else 'messenger/groupchat/'+name.lower().replace(' ', '_')+'.png' 
        # new
        def set_avatar(self, new_avatar):
            self.avatar = new_avatar
        def set_name(self, new_name):
            self.name = new_name
Usage:

Code: Select all

$ groupchat.list[0].set_avatar('messenger/groupchat/yournewavatar.png')
*But in this case, the avatar will automatically change in old messages.
**If this does not suit you, create another character with this name, but a new avatar. It is a workaround.
Thank you so much !! ^^

User avatar
sDextra
Regular
Posts: 40
Joined: Fri Oct 12, 2018 2:06 am
Organization: Event Horizon Games
Github: sDextra
Location: Kazakhstan
Contact:

Re: telegram messenger (2 version)

#90 Post by sDextra »

Update to Messenger 1.4
New: Custom Color Themes
GitHub

To create a custom theme, use the function 'set_color_theme(1,1,1)' with three arguments (red,green,blue).
For example:

Code: Select all

textbutton 'default' action Function(set_color_theme, 1.0,1.0,1.0)  # (1.0,1.0,1.0) == RGB 
textbutton 'blue' action Function(set_color_theme, .7,.7,1) # 70% red, 70% green, 100% blue
Image


Almost all saved color themes:
Image
Attachments
messenger_emulator.zip
(8.2 MiB) Downloaded 76 times
Last edited by sDextra on Tue Sep 17, 2019 9:08 pm, edited 2 times in total.

Post Reply

Who is online

Users browsing this forum: No registered users