Page 5 of 9

Re: telegram messenger (2 version)

Posted: Thu Jan 10, 2019 1:36 pm
by Nanahs
Oh, ok. Got it. Thamk you! :)

But now how I show the image inside the message?

Because the messages are working this way, like the older code like:

Code: Select all

    python:    
        msg("Hello Anna!!", who=1)
But in the new code it's like this (image and sound):

Code: Select all

    $ msg (None, audio="opening", who=1)
    $ msg (None, pic="crow", who=1)

Re: telegram messenger (2 version)

Posted: Thu Jan 10, 2019 1:48 pm
by sDextra
Nanahs wrote: Thu Jan 10, 2019 1:36 pm Oh, ok. Got it. Thamk you! :)

But now how I show the image inside the message?

Because the messages are working this way, like the older code like:

Code: Select all

    
    python:    
        msg("Hello Anna!!", who=1)
But in the new code it's like this (image and sound):

Code: Select all

    $ msg (None, audio="opening", who=1)
    $ msg (None, pic="crow", who=1)

Code: Select all

python:
    msg("Hello Anna!!", who=1)
==

Code: Select all

$ msg ("Hello Anna!!", who=1)
Just try it in your version:

Code: Select all

python:
    msg (None, pic='your_pic', who=1)
Path to the image: 'images/messenger/pic/*your_pic*.jpg'

Re: telegram messenger (2 version)

Posted: Thu Jan 10, 2019 3:16 pm
by Nanahs
sDextra wrote: Thu Jan 10, 2019 1:48 pm
Nanahs wrote: Thu Jan 10, 2019 1:36 pm Oh, ok. Got it. Thamk you! :)

But now how I show the image inside the message?

Because the messages are working this way, like the older code like:

Code: Select all

    
    python:    
        msg("Hello Anna!!", who=1)
But in the new code it's like this (image and sound):

Code: Select all

    $ msg (None, audio="opening", who=1)
    $ msg (None, pic="crow", who=1)

Code: Select all

python:
    msg("Hello Anna!!", who=1)
==

Code: Select all

$ msg ("Hello Anna!!", who=1)
Just try it in your version:

Code: Select all

python:
    msg (None, pic='your_pic', who=1)
Path to the image: 'images/messenger/pic/*your_pic*.jpg'
Thank you! It worked with the image.

Only two things are not working.
I'm getting embarrassed from making so many questions. Sorry :oops: :oops: :lol:

The audio didn't work:

Code: Select all

    python:
        msg (None, audio="birds", who=1)
I got this error:

Code: Select all

    While running game code:
  File "game/script.rpy", line 487, in script
    python:
  File "game/script.rpy", line 488, in <module>
    msg (None, audio="birds", who=1)
TypeError: msg() got an unexpected keyword argument 'audio'
I have an "audio" folder and the "birds.mp3" inside it.

PS: I changed "audio" to "sound". The audio player shows up. But when I click to play, it keeps telling me it could find "birds" file even though it's there.

I also this. To make the message go "automatic", without the person clicking on the screen. I added "p" in "renpy.pause(p)".
It was really good, cause I could use "p=3" for short messages, "p=6" for biggers messages, etc. Control how long the other character was "typing" and then automatically send it.

So the message would be:

Code: Select all

    python:    
        msg("Hello Anna!", p=3, who=1)
And I did the same thing in this new code:

Code: Select all

    def msg(txt, who=False, sound=False, pic=False, hm=False):
        if message_time:
            h,m = message_time
            hm = hm if hm else '%s:%s'%(h,m)
            time_update()
        hm = get_current_time() if message_time_current else hm 

        store.m_msg.append((who, txt, sound, pic, hm))
        store.yadj.value = store.yadj.range+300
        renpy.restart_interaction()
        if who:
            renpy.play("new_message.mp3", "sound")
        renpy.pause(p)
But I keep getting the error "global name 'p' is not defined". Why is it not defined if I added it "renpy.pause(p)". It worked in the other code :?:

Re: telegram messenger (2 version)

Posted: Thu Jan 10, 2019 3:57 pm
by sDextra
Nanahs wrote: Thu Jan 10, 2019 1:36 pm So the message would be:

Code: Select all

    python:    
        msg("Hello Anna!", p=3, who=1)
And I did the same thing in this new code:

Code: Select all

    def msg(txt, who=False, sound=False, pic=False, hm=False):
        if message_time:
            h,m = message_time
            hm = hm if hm else '%s:%s'%(h,m)
            time_update()
        hm = get_current_time() if message_time_current else hm 

        store.m_msg.append((who, txt, sound, pic, hm))
        store.yadj.value = store.yadj.range+300
        renpy.restart_interaction()
        if who:
            renpy.play("new_message.mp3", "sound")
        renpy.pause(p)
But I keep getting the error "global name 'p' is not defined". Why is it not defined if I added it "renpy.pause(p)". It worked in the other code :?:

You forgot about the keyword argument:

Code: Select all

def msg(txt, who=False, sound=False, pic=False, hm=False, p=1) ### 'p=default'

Re: telegram messenger (2 version)

Posted: Fri Jan 11, 2019 12:13 pm
by Nanahs
sDextra wrote: Thu Jan 10, 2019 3:57 pm
Nanahs wrote: Thu Jan 10, 2019 1:36 pm So the message would be:

Code: Select all

    python:    
        msg("Hello Anna!", p=3, who=1)
And I did the same thing in this new code:

Code: Select all

    def msg(txt, who=False, sound=False, pic=False, hm=False):
        if message_time:
            h,m = message_time
            hm = hm if hm else '%s:%s'%(h,m)
            time_update()
        hm = get_current_time() if message_time_current else hm 

        store.m_msg.append((who, txt, sound, pic, hm))
        store.yadj.value = store.yadj.range+300
        renpy.restart_interaction()
        if who:
            renpy.play("new_message.mp3", "sound")
        renpy.pause(p)
But I keep getting the error "global name 'p' is not defined". Why is it not defined if I added it "renpy.pause(p)". It worked in the other code :?:

You forgot about the keyword argument:

Code: Select all

def msg(txt, who=False, sound=False, pic=False, hm=False, p=1) ### 'p=default'
Thank you so much :)

Re: telegram messenger (2 version)

Posted: Fri Jan 11, 2019 2:39 pm
by Nanahs
Do you know what this error means?

Code: Select all

While running game code:
  File "game/script.rpy", line 456, in script
    python:
  File "game/script.rpy", line 457, in <module>
    msg (None, sound="opening.mp3", who=1)
TypeError: unsupported operand type(s) for -: 'ATLTransform' and 'float'
It shows up whenever I try to use any of those codes:

Code: Select all

    python:
        msg (None, sound="birds.mp3", who=1)


    python:
        msg (None, sound="birds", who=1)


    python:
        msg("", who=1, sound="birds.mp3")        


    python:
        msg (None, audio="birds.mp3", who=1)

Re: telegram messenger (2 version)

Posted: Fri Jan 11, 2019 5:13 pm
by sDextra
Nanahs wrote: Fri Jan 11, 2019 2:39 pm Do you know what this error means?

Code: Select all

While running game code:
  File "game/script.rpy", line 456, in script
    python:
  File "game/script.rpy", line 457, in <module>
    msg (None, sound="opening.mp3", who=1)
TypeError: unsupported operand type(s) for -: 'ATLTransform' and 'float'
It shows up whenever I try to use any of those codes:

Code: Select all

    python:
        msg (None, sound="birds.mp3", who=1)


    python:
        msg (None, sound="birds", who=1)


    python:
        msg("", who=1, sound="birds.mp3")        


    python:
        msg (None, audio="birds.mp3", who=1)
I do not see this line: 'msg (None, sound="opening.mp3", who=1)'
Why there is both 'sound' and 'audio'. In the old version 'sound', in the new 'audio', they replace each other.

I do not have old version, so I can not say exactly what the problem is. :?:
Сan you send your project in PM? I will try to solve the problem.

Re: telegram messenger (2 version)

Posted: Fri Jan 11, 2019 10:34 pm
by Nanahs
sDextra wrote: Fri Jan 11, 2019 5:13 pm
Nanahs wrote: Fri Jan 11, 2019 2:39 pm Do you know what this error means?

Code: Select all

While running game code:
  File "game/script.rpy", line 456, in script
    python:
  File "game/script.rpy", line 457, in <module>
    msg (None, sound="opening.mp3", who=1)
TypeError: unsupported operand type(s) for -: 'ATLTransform' and 'float'
It shows up whenever I try to use any of those codes:

Code: Select all

    python:
        msg (None, sound="birds.mp3", who=1)


    python:
        msg (None, sound="birds", who=1)


    python:
        msg("", who=1, sound="birds.mp3")        


    python:
        msg (None, audio="birds.mp3", who=1)
I do not see this line: 'msg (None, sound="opening.mp3", who=1)'
Why there is both 'sound' and 'audio'. In the old version 'sound', in the new 'audio', they replace each other.

I do not have old version, so I can not say exactly what the problem is. :?:
Сan you send your project in PM? I will try to solve the problem.
Thank you so much! I sent you the project :)

Re: telegram messenger (2 version)

Posted: Fri May 03, 2019 4:52 pm
by nanashine
Hello! Can I make just one more question? hahah :oops:

This is my audio channel:

Code: Select all

init python:
    renpy.music.register_channel("player", mixer='sfx', loop=False, stop_on_mute=True) 
And this is the messenger screen code:

Code: Select all

screen telegram():
    frame background "messenger/back.png" xysize (700,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, pic, hm = message
                        $ xgn = 0.0 if who else 1.0
                        $ xpic = 380
                        if sound:
                            hbox spacing -60 xalign xgn:
                                $ sound = 'sfx/%s.mp3'%(sound)
                                imagebutton auto "messenger/sound_%s.png" xalign xgn action Play("player", sound)
                                if hm:
                                    text "{t}%s{/t}"%(hm) style 'txt_time'
                        elif pic:
                            hbox spacing -60 xalign xgn:
                                button xalign xgn xmaximum 580 xpadding 4 top_padding 30 bottom_padding 40 background 'box' hover_background 'h_box':
                                    action Show('full_pic', pic=pic)
                                    add "messenger/pic/%s.jpg"%(pic) size (380, 600)
                                if hm:
                                    text "{t}%s{/t}"%(hm) style 'txt_time'
                        else: 
                            hbox spacing -60 xalign xgn:
                                button xalign xgn xmaximum 580 xpadding 20 top_padding 10 bottom_padding 30 background 'box':
                                    text "%s"%(txt) style "txt_base"
                                if hm:
                                    text "{t}%s{/t}"%(hm) style 'txt_time'

        # Bar
        vbar value YScrollValue("vp_msg") style "bar_vert"
~

When I click to play the audio it works normally. But when I click again, the audio doesn't stop playing.
It plays the audio again, instead of being a "play/stop" button.
Is there a way I can change it in this code?
I created a separate button to do it, but it's not practical at all.

Thanks.

Re: telegram messenger (2 version)

Posted: Fri May 03, 2019 6:25 pm
by sDextra
nanashine wrote: Fri May 03, 2019 4:52 pm Hello! Can I make just one more question? hahah :oops:

This is my audio channel:

Code: Select all

init python:
    renpy.music.register_channel("player", mixer='sfx', loop=False, stop_on_mute=True) 
And this is the messenger screen code:

Code: Select all

screen telegram():
    frame background "messenger/back.png" xysize (700,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, pic, hm = message
                        $ xgn = 0.0 if who else 1.0
                        $ xpic = 380
                        if sound:
                            hbox spacing -60 xalign xgn:
                                $ sound = 'sfx/%s.mp3'%(sound)
                                imagebutton auto "messenger/sound_%s.png" xalign xgn action Play("player", sound)
                                if hm:
                                    text "{t}%s{/t}"%(hm) style 'txt_time'
                        elif pic:
                            hbox spacing -60 xalign xgn:
                                button xalign xgn xmaximum 580 xpadding 4 top_padding 30 bottom_padding 40 background 'box' hover_background 'h_box':
                                    action Show('full_pic', pic=pic)
                                    add "messenger/pic/%s.jpg"%(pic) size (380, 600)
                                if hm:
                                    text "{t}%s{/t}"%(hm) style 'txt_time'
                        else: 
                            hbox spacing -60 xalign xgn:
                                button xalign xgn xmaximum 580 xpadding 20 top_padding 10 bottom_padding 30 background 'box':
                                    text "%s"%(txt) style "txt_base"
                                if hm:
                                    text "{t}%s{/t}"%(hm) style 'txt_time'

        # Bar
        vbar value YScrollValue("vp_msg") style "bar_vert"
~

When I click to play the audio it works normally. But when I click again, the audio doesn't stop playing.
It plays the audio again, instead of being a "play/stop" button.
Is there a way I can change it in this code?
I created a separate button to do it, but it's not practical at all.

Thanks.
Hmm, you can try something like that

Code: Select all

screen telegram():
    frame background "messenger/back.png" xysize (700,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, pic, hm = message
                        $ xgn = 0.0 if who else 1.0
                        $ xpic = 380
                        if sound:
                            $ sound = 'sfx/%s.mp3'%(sound)
                            $ playing = renpy.music.get_playing(channel='player')
                            $ now_play = sound == playing
                            hbox spacing -60 xalign xgn:
                                imagebutton auto "messenger/sound_%s.png" xalign xgn action If(now_play, [Stop('player')], [Play('player', sound)]):
                                if hm:
                                    text "{t}%s{/t}"%(hm) style 'txt_time'
                        elif pic:
                            hbox spacing -60 xalign xgn:
                                button xalign xgn xmaximum 580 xpadding 4 top_padding 30 bottom_padding 40 background 'box' hover_background 'h_box':
                                    action Show('full_pic', pic=pic)
                                    add "messenger/pic/%s.jpg"%(pic) size (380, 600)
                                if hm:
                                    text "{t}%s{/t}"%(hm) style 'txt_time'
                        else: 
                            hbox spacing -60 xalign xgn:
                                button xalign xgn xmaximum 580 xpadding 20 top_padding 10 bottom_padding 30 background 'box':
                                    text "%s"%(txt) style "txt_base"
                                if hm:
                                    text "{t}%s{/t}"%(hm) style 'txt_time'

        # Bar
        vbar value YScrollValue("vp_msg") style "bar_vert"

Re: telegram messenger (2 version)

Posted: Sat May 04, 2019 8:24 am
by nanashine
Thank you so much sDextra! It worked :)

Re: telegram messenger (2 version)

Posted: Sun May 05, 2019 7:53 am
by Godline
Hey sDextra!
Used this code in our LDjam game: https://ldjam.com/events/ludum-dare/44/ ... of-romance

(credited)
Thanks so much! <3

Re: telegram messenger (2 version)

Posted: Mon Jun 24, 2019 9:15 am
by fauxbius
This code is amazing, thanks!

Quick questions:

Is it possible to stop the script progressing until the name input has been completed?

Once I've put in the name, does it have to display as a text? I'd prefer to input the name, then on a new line put "Oh hi, [name]" instead of just having the name on it's own

Is it possible to show clickable playable videos?

Re: telegram messenger (2 version)

Posted: Mon Jun 24, 2019 10:38 am
by sDextra
fauxbius wrote: Mon Jun 24, 2019 9:15 am Is it possible to stop the script progressing until the name input has been completed?
If I understand you correctly, you can try using this function:

Code: Select all

$ freeze() 
# your actions
$ unfreeze()
fauxbius wrote: Mon Jun 24, 2019 9:15 am Once I've put in the name, does it have to display as a text? I'd prefer to input the name, then on a new line put "Oh hi, [name]" instead of just having the name on it's own
This is already implemented in the code.
Image

fauxbius wrote: Mon Jun 24, 2019 9:15 am Is it possible to show clickable playable videos?
I think it is possible, but it will take some time.

Re: telegram messenger (2 version)

Posted: Mon Jun 24, 2019 12:22 pm
by fauxbius
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]")
sDextra wrote: Mon Jun 24, 2019 10:38 am I think it is possible, but it will take some time.
Thanks for the help!