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)

#31 Post by sDextra »

zeroTheHero wrote: Thu Oct 11, 2018 8:29 am
Andredron wrote: Wed Oct 10, 2018 1:16 am
zeroTheHero wrote: Tue Oct 09, 2018 11:07 am Hey, how do I make the text in messenger in italics?
Text tag

"{i} text{\i}"
I tried

Code: Select all

msg("Привет,{i} text{\i} всё хорошо, а как у тебя?")
but no dice

Code: Select all

Exception: unknown text tag u'\\i'
It'd be amazing if we could use {w} and {b} and all the other cool tags in this...

Thanks for your time ^_^
Try it
{i}Text{/i}

User avatar
Andredron
Miko-Class Veteran
Posts: 700
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: telegram messenger (2 version)

#32 Post by Andredron »

zeroTheHero wrote: Thu Oct 11, 2018 8:29 am
Andredron wrote: Wed Oct 10, 2018 1:16 am
zeroTheHero wrote: Tue Oct 09, 2018 11:07 am Hey, how do I make the text in messenger in italics?
Text tag

"{i} text{\i}"
I tried

Code: Select all

msg("Привет,{i} text{\i} всё хорошо, а как у тебя?")
but no dice

Code: Select all

Exception: unknown text tag u'\\i'
It'd be amazing if we could use {w} and {b} and all the other cool tags in this...

Thanks for your time ^_^

my error

Image

Image

User avatar
Andredron
Miko-Class Veteran
Posts: 700
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: telegram messenger (2 version)

#33 Post by Andredron »

Image

Box_two
Image
Last edited by Andredron on Sat Nov 17, 2018 9:43 am, edited 2 times in total.

User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: telegram messenger (2 version)

#34 Post by Nanahs »

Andredron wrote: Fri Oct 12, 2018 2:43 am
Nanahs wrote: Mon Oct 01, 2018 8:35 pm
Andredron wrote: Fri Sep 14, 2018 5:17 pm Please, whoever can check both versions how they work on android and iphone. Friend wrote: a bug and the image does not show
Hello! On the first version of the messenger, can I have different message boxes? Like, the gray one for the character that's talking to you, and yours be another color? (green, blue, etc).
How could I add this? (if possible)
Thanks :)
Image
https://pp.userapi.com/c849136/v8491365 ... GL10wk.jpg

Code: Select all

Xalign xgn xmaximum 580 xpadding 20 ypadding 10 button:
.... if anyone == 1:
........ frame background ("messenger / box_two.png", 25, 25)
....else:
. ....... background Frame ("messenger / box.png", 25, 25)
Box_two
Image

Thank you so much! I just got confused, which part of the code I can delete and replace with this one?

Code: Select all

screen telegram():
    frame background "messenger/back.png" xysize (600,975) align (0.9,.5):
        frame background None xysize (560, 810) align (0.5,0.58):
            viewport id "vp_msg" mousewheel True  yadjustment yadj:
                vbox spacing 15 xsize 550 xalign 0.4 box_reverse True:
                    for message in m_msg[::-1]:
                        $ who, txt, sound = message
                        $ xgn = 0.0 if who else 1.0
                        if sound:
                            imagebutton auto "messenger/sound_%s.png" xalign xgn action Play("sound", sound)
                        else: 
                            button xalign xgn xmaximum 580 xpadding 20 ypadding 10 background Frame("messenger/box.png", 25, 25):
                                text "%s"%(txt) style "txt_base"
                                

        # Имя собеседника
        text "%s"%(msg_name) style "txt_base" size 35 xalign 0.31 xanchor 0.0 yalign 0.04
        # Аватарка собеседника
        add "messenger/av/"+msg_name.lower().replace(' ', '_')+".png" pos (100,27)
        # Стрелка
        imagebutton auto "messenger/arr_%s.png" pos (10, 33) action NullAction()
        # Стереть сообщения
        button background style_button_inst hover_background style_button_hovr xalign 0.99 yalign 0.03 action Function(del_all_msg) xysize (60,60):
            text "  x  " style "txt_base" size 40 pos (36, -2) 
        # Ползунок прокрутки
        vbar value YScrollValue("vp_msg") style "bar_vert"
I tried but it kept giving me errors :?:
Sorry I'm still slow, still learning :D
Thank you!

zeroTheHero
Regular
Posts: 64
Joined: Mon May 07, 2018 10:49 am
Contact:

Re: telegram messenger (2 version)

#35 Post by zeroTheHero »

Hey Andredon and Valentin! I've been trying to add a choice system to your code that shows you choices within the messenger itself and not like the ones when you use 'menu'. It works swimmingly but there's a small problem. It'll be easier to explain if you just see the code:

Code: Select all

#in messenger.rpy
def msg(txt, choice1=False, choice2=False,choice3=False, who=False, sound=False):   #Just added these variables 'choice'
        store.m_msg.append((who, txt, choice1,choice2,choice3, sound))
        store.yadj.value = store.yadj.range+300
        renpy.restart_interaction()
        if who:
            renpy.play("new_message.mp3", "sound")
        renpy.pause()
--snip--
screen telegram():
	~~snip~~
                    for message in m_msg[::-1]:
                        $ who, txt, choice1,choice2,choice3, sound = message
                        $ xgn = 0.0 if who else 1.0
                        if sound:
                            imagebutton auto "messenger/sound_%s.png" xalign xgn action Play("sound", sound)
                        elif choice1:                                                                           #
                            frame background Frame("messenger/box.png"):                                        #
                                    xysize(720,275)                                                             #Just
                                    align (0.1, 0.1)                                                            #Added
                                    vbox:                                                                       #These
                                        yalign 0.5                                                              #Lines
                                        textbutton "%s"%(choice1) hover_background "#00a" action Function(del_all_msg), Jump("window") #
                                        textbutton "%s"%(choice2) hover_background "#00a" action Function(del_all_msg), Jump("door")   #
                        else: 
                            button xalign xgn xmaximum 580 xpadding 20 ypadding 10  background Frame("messenger/box.png", 25, 25):
                                # image "charmander1.png"
                                text "%s"%(txt) style "txt_base"

Code: Select all

#in the script.rpy file
--snip--
    python:
        msg("You MUST get those cookies back!")
        msg("But what can we do?...")
        msg("We could sneak in from the window...", who=1)
        msg("Or we could just walk in the front door!",who=1)
        msg("What should we do?")
        msg("", choice1="Sneak in through the window", choice2="Walk through the door")
        
label window:
    python:
        msg("Kacha! You accidently broke the window")
        msg("Your neighbour appears")
        msg("Fi Fy Fo Fum broke my window, you Scum!")
        msg("You run")
    return
        
label door:
    python:
        msg("Your strength is insufficient. You can't even open a door!")
        msg("You can smell your cookies")
        msg("Your hunger increases and it gives you strength!")
        msg("You push the door again and accidently break the house!")
    return
See, the choices work as long as you click the textbuttons. But if I click outside the 'choice' frame the game moves on to the next label, irrespective of whether any choice is made or not!
I don't know how to fix this... I made a post with this question and it seems using the 'call' statement halts the game until a textbutton is pressed...but I don't know how to put 'call' in the code.
Do you have any idea on how to fix this? Or is this not the way to do it?
Help would be appreciated! I find myself coming back here often, and you guys are kind enough to always show me the way, so thanks a ton!
Have a great day~

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)

#36 Post by sDextra »

Nanahs wrote: Fri Oct 12, 2018 11:11 am
Andredron wrote: Fri Oct 12, 2018 2:43 am
Nanahs wrote: Mon Oct 01, 2018 8:35 pm

Hello! On the first version of the messenger, can I have different message boxes? Like, the gray one for the character that's talking to you, and yours be another color? (green, blue, etc).
How could I add this? (if possible)
Thanks :)
Image
https://pp.userapi.com/c849136/v8491365 ... GL10wk.jpg

Code: Select all

Xalign xgn xmaximum 580 xpadding 20 ypadding 10 button:
.... if anyone == 1:
........ frame background ("messenger / box_two.png", 25, 25)
....else:
. ....... background Frame ("messenger / box.png", 25, 25)
Box_two
Image

Thank you so much! I just got confused, which part of the code I can delete and replace with this one?

Code: Select all

screen telegram():
    frame background "messenger/back.png" xysize (600,975) align (0.9,.5):
        frame background None xysize (560, 810) align (0.5,0.58):
            viewport id "vp_msg" mousewheel True  yadjustment yadj:
                vbox spacing 15 xsize 550 xalign 0.4 box_reverse True:
                    for message in m_msg[::-1]:
                        $ who, txt, sound = message
                        $ xgn = 0.0 if who else 1.0
                        if sound:
                            imagebutton auto "messenger/sound_%s.png" xalign xgn action Play("sound", sound)
                        else: 
                            button xalign xgn xmaximum 580 xpadding 20 ypadding 10 background Frame("messenger/box.png", 25, 25):
                                text "%s"%(txt) style "txt_base"
                                

        # Имя собеседника
        text "%s"%(msg_name) style "txt_base" size 35 xalign 0.31 xanchor 0.0 yalign 0.04
        # Аватарка собеседника
        add "messenger/av/"+msg_name.lower().replace(' ', '_')+".png" pos (100,27)
        # Стрелка
        imagebutton auto "messenger/arr_%s.png" pos (10, 33) action NullAction()
        # Стереть сообщения
        button background style_button_inst hover_background style_button_hovr xalign 0.99 yalign 0.03 action Function(del_all_msg) xysize (60,60):
            text "  x  " style "txt_base" size 40 pos (36, -2) 
        # Ползунок прокрутки
        vbar value YScrollValue("vp_msg") style "bar_vert"
I tried but it kept giving me errors :?:
Sorry I'm still slow, still learning :D
Thank you!
Try it
P.S.: Copy the image "box.png", change its color and rename it to "box_two.png"

Code: Select all

screen telegram():
    frame background "messenger/back.png" xysize (600,975) align (0.9,.5):
        frame background None xysize (560, 810) align (0.5,0.58):
            viewport id "vp_msg" mousewheel True  yadjustment yadj:
                vbox spacing 15 xsize 550 xalign 0.4 box_reverse True:
                    for message in m_msg[::-1]:
                        $ who, txt, sound = message
                        $ xgn = 0.0 if who else 1.0
                        if sound:
                            imagebutton auto "messenger/sound_%s.png" xalign xgn action Play("sound", sound)
                        else: 
                            button xalign xgn xmaximum 580 xpadding 20 ypadding 10:
                            	
                            	### NEW PART
                                if who == 1:
                                    background Frame("messenger/box_two.png", 25, 25)
                                else:
                                    background Frame("messenger/box.png", 25, 25)
                                ###
                                    
                                text "%s"%(txt) style "txt_base"

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)

#37 Post by sDextra »

zeroTheHero wrote: Sat Nov 17, 2018 2:00 am Hey Andredon and Valentin! I've been trying to add a choice system to your code that shows you choices within the messenger itself and not like the ones when you use 'menu'. It works swimmingly but there's a small problem. It'll be easier to explain if you just see the code:

Code: Select all

#in messenger.rpy
def msg(txt, choice1=False, choice2=False,choice3=False, who=False, sound=False):   #Just added these variables 'choice'
        store.m_msg.append((who, txt, choice1,choice2,choice3, sound))
        store.yadj.value = store.yadj.range+300
        renpy.restart_interaction()
        if who:
            renpy.play("new_message.mp3", "sound")
        renpy.pause()
--snip--
screen telegram():
	~~snip~~
                    for message in m_msg[::-1]:
                        $ who, txt, choice1,choice2,choice3, sound = message
                        $ xgn = 0.0 if who else 1.0
                        if sound:
                            imagebutton auto "messenger/sound_%s.png" xalign xgn action Play("sound", sound)
                        elif choice1:                                                                           #
                            frame background Frame("messenger/box.png"):                                        #
                                    xysize(720,275)                                                             #Just
                                    align (0.1, 0.1)                                                            #Added
                                    vbox:                                                                       #These
                                        yalign 0.5                                                              #Lines
                                        textbutton "%s"%(choice1) hover_background "#00a" action Function(del_all_msg), Jump("window") #
                                        textbutton "%s"%(choice2) hover_background "#00a" action Function(del_all_msg), Jump("door")   #
                        else: 
                            button xalign xgn xmaximum 580 xpadding 20 ypadding 10  background Frame("messenger/box.png", 25, 25):
                                # image "charmander1.png"
                                text "%s"%(txt) style "txt_base"

Code: Select all

#in the script.rpy file
--snip--
    python:
        msg("You MUST get those cookies back!")
        msg("But what can we do?...")
        msg("We could sneak in from the window...", who=1)
        msg("Or we could just walk in the front door!",who=1)
        msg("What should we do?")
        msg("", choice1="Sneak in through the window", choice2="Walk through the door")
        
label window:
    python:
        msg("Kacha! You accidently broke the window")
        msg("Your neighbour appears")
        msg("Fi Fy Fo Fum broke my window, you Scum!")
        msg("You run")
    return
        
label door:
    python:
        msg("Your strength is insufficient. You can't even open a door!")
        msg("You can smell your cookies")
        msg("Your hunger increases and it gives you strength!")
        msg("You push the door again and accidently break the house!")
    return
See, the choices work as long as you click the textbuttons. But if I click outside the 'choice' frame the game moves on to the next label, irrespective of whether any choice is made or not!
I don't know how to fix this... I made a post with this question and it seems using the 'call' statement halts the game until a textbutton is pressed...but I don't know how to put 'call' in the code.
Do you have any idea on how to fix this? Or is this not the way to do it?
Help would be appreciated! I find myself coming back here often, and you guys are kind enough to always show me the way, so thanks a ton!
Have a great day~
Yeah, I see.
I think you can add a hard pause after choice.
renpy.pause(9999, hard=True)

Code: Select all

#messenger.rpy
init python:
    def freeze():
    	renpy.pause(9999, hard=True)
    
#script.rpy
label start:
    python:
    	msg("Any message")
    	msg("", choice1="button1", choice2="button2")
    	freeze()
Image

But, unfortunately, it does not help if you start to skip.

P.S.: I changed your code a little.

Code: Select all

#messenger.rpy
init python:
    def msg(txt, choices=False, who=False, sound=False):
        store.m_msg.append((who, txt, choices, sound))
        store.yadj.value = store.yadj.range+300
        renpy.restart_interaction()
        if who:
            renpy.play("new_message.mp3", "sound")
        renpy.pause()

    def freeze():
        renpy.pause(9999, hard=True)
~~~~~~~~~
screen telegram():
    frame background "messenger/back.png" xysize (600,975) align (0.9,.5):
        frame background None xysize (560, 810) align (0.5,0.58):
            viewport id "vp_msg" mousewheel True  yadjustment yadj:
                vbox spacing 15 xsize 550 xalign 0.4 box_reverse True:
                    for message in m_msg[::-1]:
                        $ who, txt, choices, sound = message
                        $ xgn = 0.0 if who else 1.0
                        if sound:
                            imagebutton auto "messenger/sound_%s.png" xalign xgn action Play("sound", sound)
                        elif choices:
                            frame xalign xgn xmaximum 580 xpadding 20 ypadding 10 background Frame("messenger/box.png", 25, 25):                                                                       
                                vbox:
                                    $ sort = sorted(choices.items(), key=lambda x: x)
                                    for k, v in sort:
                                        textbutton "%s"%(v.get('name', 'choices %s'%(k) )) hover_background "#00a":
                                            action Function(del_all_msg), Jump(v.get('jump', 'start'))
                        else: 
                            button xalign xgn xmaximum 580 xpadding 20 ypadding 10 background Frame("messenger/box.png", 25, 25):
                                text "%s"%(txt) style "

~~~~~~~~~~~~

#script.rpy
label start:
    ~~~~
    python:
        msg("You MUST get those cookies back!")
        msg("But what can we do?...")
        msg("We could sneak in from the window...", who=1)
        msg("Or we could just walk in the front door!",who=1)
        msg("What should we do?")
        msg("", choices={0:{'jump':"window", 'name':"Sneak in through the window"}, 1:{'jump':"door", 'name':"Walk through the door"}})
        freeze()
Image

This way you can add as many choices as you like. For example:
Image
Image

Full Script on Pastebin

zeroTheHero
Regular
Posts: 64
Joined: Mon May 07, 2018 10:49 am
Contact:

Re: telegram messenger (2 version)

#38 Post by zeroTheHero »

sDextra wrote: Sat Nov 17, 2018 11:45 am
zeroTheHero wrote: Sat Nov 17, 2018 2:00 am Hey Andredon and Valentin! I've been trying to add a choice system to your code that shows you choices within the messenger itself and not like the ones when you use 'menu'. It works swimmingly but there's a small problem. It'll be easier to explain if you just see the code:

Code: Select all

#in messenger.rpy
def msg(txt, choice1=False, choice2=False,choice3=False, who=False, sound=False):   #Just added these variables 'choice'
        store.m_msg.append((who, txt, choice1,choice2,choice3, sound))
        store.yadj.value = store.yadj.range+300
        renpy.restart_interaction()
        if who:
            renpy.play("new_message.mp3", "sound")
        renpy.pause()
--snip--
screen telegram():
	~~snip~~
                    for message in m_msg[::-1]:
                        $ who, txt, choice1,choice2,choice3, sound = message
                        $ xgn = 0.0 if who else 1.0
                        if sound:
                            imagebutton auto "messenger/sound_%s.png" xalign xgn action Play("sound", sound)
                        elif choice1:                                                                           #
                            frame background Frame("messenger/box.png"):                                        #
                                    xysize(720,275)                                                             #Just
                                    align (0.1, 0.1)                                                            #Added
                                    vbox:                                                                       #These
                                        yalign 0.5                                                              #Lines
                                        textbutton "%s"%(choice1) hover_background "#00a" action Function(del_all_msg), Jump("window") #
                                        textbutton "%s"%(choice2) hover_background "#00a" action Function(del_all_msg), Jump("door")   #
                        else: 
                            button xalign xgn xmaximum 580 xpadding 20 ypadding 10  background Frame("messenger/box.png", 25, 25):
                                # image "charmander1.png"
                                text "%s"%(txt) style "txt_base"

Code: Select all

#in the script.rpy file
--snip--
    python:
        msg("You MUST get those cookies back!")
        msg("But what can we do?...")
        msg("We could sneak in from the window...", who=1)
        msg("Or we could just walk in the front door!",who=1)
        msg("What should we do?")
        msg("", choice1="Sneak in through the window", choice2="Walk through the door")
        
label window:
    python:
        msg("Kacha! You accidently broke the window")
        msg("Your neighbour appears")
        msg("Fi Fy Fo Fum broke my window, you Scum!")
        msg("You run")
    return
        
label door:
    python:
        msg("Your strength is insufficient. You can't even open a door!")
        msg("You can smell your cookies")
        msg("Your hunger increases and it gives you strength!")
        msg("You push the door again and accidently break the house!")
    return
See, the choices work as long as you click the textbuttons. But if I click outside the 'choice' frame the game moves on to the next label, irrespective of whether any choice is made or not!
I don't know how to fix this... I made a post with this question and it seems using the 'call' statement halts the game until a textbutton is pressed...but I don't know how to put 'call' in the code.
Do you have any idea on how to fix this? Or is this not the way to do it?
Help would be appreciated! I find myself coming back here often, and you guys are kind enough to always show me the way, so thanks a ton!
Have a great day~
Yeah, I see.
I think you can add a hard pause after choice.
renpy.pause(9999, hard=True)

Code: Select all

#messenger.rpy
init python:
    def freeze():
    	renpy.pause(9999, hard=True)
    
#script.rpy
label start:
    python:
    	msg("Any message")
    	msg("", choice1="button1", choice2="button2")
    	freeze()
Image

But, unfortunately, it does not help if you start to skip.

P.S.: I changed your code a little.

Code: Select all

#messenger.rpy
init python:
    def msg(txt, choices=False, who=False, sound=False):
        store.m_msg.append((who, txt, choices, sound))
        store.yadj.value = store.yadj.range+300
        renpy.restart_interaction()
        if who:
            renpy.play("new_message.mp3", "sound")
        renpy.pause()

    def freeze():
        renpy.pause(9999, hard=True)
~~~~~~~~~
screen telegram():
    frame background "messenger/back.png" xysize (600,975) align (0.9,.5):
        frame background None xysize (560, 810) align (0.5,0.58):
            viewport id "vp_msg" mousewheel True  yadjustment yadj:
                vbox spacing 15 xsize 550 xalign 0.4 box_reverse True:
                    for message in m_msg[::-1]:
                        $ who, txt, choices, sound = message
                        $ xgn = 0.0 if who else 1.0
                        if sound:
                            imagebutton auto "messenger/sound_%s.png" xalign xgn action Play("sound", sound)
                        elif choices:
                            frame xalign xgn xmaximum 580 xpadding 20 ypadding 10 background Frame("messenger/box.png", 25, 25):                                                                       
                                vbox:
                                    $ sort = sorted(choices.items(), key=lambda x: x)
                                    for k, v in sort:
                                        textbutton "%s"%(v.get('name', 'choices %s'%(k) )) hover_background "#00a":
                                            action Function(del_all_msg), Jump(v.get('jump', 'start'))
                        else: 
                            button xalign xgn xmaximum 580 xpadding 20 ypadding 10 background Frame("messenger/box.png", 25, 25):
                                text "%s"%(txt) style "

~~~~~~~~~~~~

#script.rpy
label start:
    ~~~~
    python:
        msg("You MUST get those cookies back!")
        msg("But what can we do?...")
        msg("We could sneak in from the window...", who=1)
        msg("Or we could just walk in the front door!",who=1)
        msg("What should we do?")
        msg("", choices={0:{'jump':"window", 'name':"Sneak in through the window"}, 1:{'jump':"door", 'name':"Walk through the door"}})
        freeze()
Image

This way you can add as many choices as you like. For example:
Image
Image

Full Script on Pastebin
To think I spent 2 days on this XD Thanks a ton, you're da real MVP! 8) :P

Edit: and ofc I just had to read it till when you suggested renpy.pause and thought thats where your post ended...now I had the skip issue and see you've already solved it for me... with code thats so much better than mine I will probably have to spend all morning just to understand.
I swear man, 80% of whatever I know of renpy comes from this post. Thanks a million, really appreciate it!

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)

#39 Post by sDextra »

zeroTheHero wrote: Sun Nov 18, 2018 11:35 pm
sDextra wrote: Sat Nov 17, 2018 11:45 am
zeroTheHero wrote: Sat Nov 17, 2018 2:00 am Hey Andredon and Valentin! I've been trying to add a choice system to your code that shows you choices within the messenger itself and not like the ones when you use 'menu'. It works swimmingly but there's a small problem. It'll be easier to explain if you just see the code:

Code: Select all

#in messenger.rpy
def msg(txt, choice1=False, choice2=False,choice3=False, who=False, sound=False):   #Just added these variables 'choice'
        store.m_msg.append((who, txt, choice1,choice2,choice3, sound))
        store.yadj.value = store.yadj.range+300
        renpy.restart_interaction()
        if who:
            renpy.play("new_message.mp3", "sound")
        renpy.pause()
--snip--
screen telegram():
	~~snip~~
                    for message in m_msg[::-1]:
                        $ who, txt, choice1,choice2,choice3, sound = message
                        $ xgn = 0.0 if who else 1.0
                        if sound:
                            imagebutton auto "messenger/sound_%s.png" xalign xgn action Play("sound", sound)
                        elif choice1:                                                                           #
                            frame background Frame("messenger/box.png"):                                        #
                                    xysize(720,275)                                                             #Just
                                    align (0.1, 0.1)                                                            #Added
                                    vbox:                                                                       #These
                                        yalign 0.5                                                              #Lines
                                        textbutton "%s"%(choice1) hover_background "#00a" action Function(del_all_msg), Jump("window") #
                                        textbutton "%s"%(choice2) hover_background "#00a" action Function(del_all_msg), Jump("door")   #
                        else: 
                            button xalign xgn xmaximum 580 xpadding 20 ypadding 10  background Frame("messenger/box.png", 25, 25):
                                # image "charmander1.png"
                                text "%s"%(txt) style "txt_base"

Code: Select all

#in the script.rpy file
--snip--
    python:
        msg("You MUST get those cookies back!")
        msg("But what can we do?...")
        msg("We could sneak in from the window...", who=1)
        msg("Or we could just walk in the front door!",who=1)
        msg("What should we do?")
        msg("", choice1="Sneak in through the window", choice2="Walk through the door")
        
label window:
    python:
        msg("Kacha! You accidently broke the window")
        msg("Your neighbour appears")
        msg("Fi Fy Fo Fum broke my window, you Scum!")
        msg("You run")
    return
        
label door:
    python:
        msg("Your strength is insufficient. You can't even open a door!")
        msg("You can smell your cookies")
        msg("Your hunger increases and it gives you strength!")
        msg("You push the door again and accidently break the house!")
    return
See, the choices work as long as you click the textbuttons. But if I click outside the 'choice' frame the game moves on to the next label, irrespective of whether any choice is made or not!
I don't know how to fix this... I made a post with this question and it seems using the 'call' statement halts the game until a textbutton is pressed...but I don't know how to put 'call' in the code.
Do you have any idea on how to fix this? Or is this not the way to do it?
Help would be appreciated! I find myself coming back here often, and you guys are kind enough to always show me the way, so thanks a ton!
Have a great day~
Yeah, I see.
I think you can add a hard pause after choice.
renpy.pause(9999, hard=True)

Code: Select all

#messenger.rpy
init python:
    def freeze():
    	renpy.pause(9999, hard=True)
    
#script.rpy
label start:
    python:
    	msg("Any message")
    	msg("", choice1="button1", choice2="button2")
    	freeze()
Image

But, unfortunately, it does not help if you start to skip.

P.S.: I changed your code a little.

Code: Select all

#messenger.rpy
init python:
    def msg(txt, choices=False, who=False, sound=False):
        store.m_msg.append((who, txt, choices, sound))
        store.yadj.value = store.yadj.range+300
        renpy.restart_interaction()
        if who:
            renpy.play("new_message.mp3", "sound")
        renpy.pause()

    def freeze():
        renpy.pause(9999, hard=True)
~~~~~~~~~
screen telegram():
    frame background "messenger/back.png" xysize (600,975) align (0.9,.5):
        frame background None xysize (560, 810) align (0.5,0.58):
            viewport id "vp_msg" mousewheel True  yadjustment yadj:
                vbox spacing 15 xsize 550 xalign 0.4 box_reverse True:
                    for message in m_msg[::-1]:
                        $ who, txt, choices, sound = message
                        $ xgn = 0.0 if who else 1.0
                        if sound:
                            imagebutton auto "messenger/sound_%s.png" xalign xgn action Play("sound", sound)
                        elif choices:
                            frame xalign xgn xmaximum 580 xpadding 20 ypadding 10 background Frame("messenger/box.png", 25, 25):                                                                       
                                vbox:
                                    $ sort = sorted(choices.items(), key=lambda x: x)
                                    for k, v in sort:
                                        textbutton "%s"%(v.get('name', 'choices %s'%(k) )) hover_background "#00a":
                                            action Function(del_all_msg), Jump(v.get('jump', 'start'))
                        else: 
                            button xalign xgn xmaximum 580 xpadding 20 ypadding 10 background Frame("messenger/box.png", 25, 25):
                                text "%s"%(txt) style "

~~~~~~~~~~~~

#script.rpy
label start:
    ~~~~
    python:
        msg("You MUST get those cookies back!")
        msg("But what can we do?...")
        msg("We could sneak in from the window...", who=1)
        msg("Or we could just walk in the front door!",who=1)
        msg("What should we do?")
        msg("", choices={0:{'jump':"window", 'name':"Sneak in through the window"}, 1:{'jump':"door", 'name':"Walk through the door"}})
        freeze()
Image

This way you can add as many choices as you like. For example:
Image
Image

Full Script on Pastebin
To think I spent 2 days on this XD Thanks a ton, you're da real MVP! 8) :P

Edit: and ofc I just had to read it till when you suggested renpy.pause and thought thats where your post ended...now I had the skip issue and see you've already solved it for me... with code thats so much better than mine I will probably have to spend all morning just to understand.
I swear man, 80% of whatever I know of renpy comes from this post. Thanks a million, really appreciate it!
I found how to block 'Skip'.

Code: Select all

#in messenger.rpy
    def freeze():
        renpy.config.skipping = False
        store._skipping = False
        renpy.pause(9999, hard=True)
    def unfreeze():
        store._skipping = True   
    ~~~~
    screen telegram():
    	~~~
    	    ~~~
    	        ~~~
    		    textbutton "%s"%(v.get('name', 'choices %s'%(k) )) hover_background "#00a":
                        action Function(del_all_msg), Function(unfreeze), Jump(v.get('jump', 'start')) 
                        ### NEW - Function(unfreeze)                       

Code: Select all

#in script.rpy
label start:
    $ unfreeze() #it is important
    
    ~~~
    python:
        msg("", choices={0:{'jump':"window", 'name':"Sneak in through the window"}, 1:{'jump':"door", 'name':"Walk through the door"}})
        freeze()
"freeze" must be set after "choices".
"unfreeze" happens when you click on a choice.
Full Script on Pastebin

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)

#40 Post by sDextra »

Update to 'Messenger 1.1' (Telegram Emulator)
GitHub
Google Drive

Features:
  • Sending a Picture Message (Click open to full screen);
  • Sending an Audio Message (Audio Player);
  • Typewriter Mode (typing emulation);
  • Make Choices (inside the message bubble)
  • Message Search (Magnifier Icon);
  • In Search '#pic' - show all Picture Messages;
  • In Search '#audio' - show all Audio Messages.
The project uses the Python module 'mutagen' (for Audio Player)


taeffeine
Newbie
Posts: 2
Joined: Sun Dec 30, 2018 3:51 pm
Contact:

Re: telegram messenger (2 version)

#42 Post by taeffeine »

Hello,

thank you so much for making this, seriously. If you don't mind me asking, is it possible to make a groupchat with more interlocutors? How would I go about doing this? Thank you very 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)

#43 Post by sDextra »

taeffeine wrote: Sun Dec 30, 2018 4:16 pm Hello,

thank you so much for making this, seriously. If you don't mind me asking, is it possible to make a groupchat with more interlocutors? How would I go about doing this? Thank you very much!
Ok, no problem.
Messenger 1.2 (Telegram Emulator)
with Group Chat
GitHub
Attachments
messenger 1.2.zip
(8.15 MiB) Downloaded 72 times

Forestofmyown
Newbie
Posts: 2
Joined: Sun Dec 16, 2018 8:04 pm
Tumblr: forestofmyown
Contact:

Re: telegram messenger (2 version)

#44 Post by Forestofmyown »

I hope you don't mind me asking, I know this thread gets a lot of requests, but how would one go about making the phone/messenger full screen? Not so much making the messenger the full size of the renpy program, but that renpy opens to the size of the messenger and that's all there is, like if you just wanted to make a messenger simulation the full program, no opening or closing it in game?

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)

#45 Post by sDextra »

Forestofmyown wrote: Mon Dec 31, 2018 7:12 pm I hope you don't mind me asking, I know this thread gets a lot of requests, but how would one go about making the phone/messenger full screen? Not so much making the messenger the full size of the renpy program, but that renpy opens to the size of the messenger and that's all there is, like if you just wanted to make a messenger simulation the full program, no opening or closing it in game?
Hm, something like this?
Attachments
FullScreen Messenger.zip
(5.85 MiB) Downloaded 70 times

Post Reply

Who is online

Users browsing this forum: No registered users