telegram messenger (2 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
sDextra
Newbie
Posts: 4
Joined: Fri Oct 12, 2018 2:06 am
Contact:

Re: telegram messenger (2 version)

#31 Post by sDextra » Fri Oct 12, 2018 2:14 am

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
Veteran
Posts: 206
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: telegram messenger (2 version)

#32 Post by Andredron » Fri Oct 12, 2018 2:35 am

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
I know, I have terrible English
I'm writing a Renpy textbook (in Russian). I would be glad if someone translated into an English or German textbook https://yadi.sk/d/ZX_DonP63USRru Update 22.06.18

User avatar
Andredron
Veteran
Posts: 206
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: telegram messenger (2 version)

#33 Post by Andredron » Fri Oct 12, 2018 2:43 am

Image

Box_two
Image
Last edited by Andredron on Sat Nov 17, 2018 9:43 am, edited 2 times in total.
I know, I have terrible English
I'm writing a Renpy textbook (in Russian). I would be glad if someone translated into an English or German textbook https://yadi.sk/d/ZX_DonP63USRru Update 22.06.18

Nanahs
Regular
Posts: 168
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: telegram messenger (2 version)

#34 Post by Nanahs » 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
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: 37
Joined: Mon May 07, 2018 10:49 am
Contact:

Re: telegram messenger (2 version)

#35 Post by zeroTheHero » 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~

sDextra
Newbie
Posts: 4
Joined: Fri Oct 12, 2018 2:06 am
Contact:

Re: telegram messenger (2 version)

#36 Post by sDextra » Sat Nov 17, 2018 8:15 am

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"

sDextra
Newbie
Posts: 4
Joined: Fri Oct 12, 2018 2:06 am
Contact:

Re: telegram messenger (2 version)

#37 Post by sDextra » 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

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

Re: telegram messenger (2 version)

#38 Post by zeroTheHero » 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!

sDextra
Newbie
Posts: 4
Joined: Fri Oct 12, 2018 2:06 am
Contact:

Re: telegram messenger (2 version)

#39 Post by sDextra » Tue Nov 27, 2018 11:21 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users