telegram messenger (4 version)
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.
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.
-
- Newbie
- Posts: 2
- Joined: Sun Dec 16, 2018 8:04 pm
- Tumblr: forestofmyown
- Contact:
Re: telegram messenger (2 version)
Thank you! That's great!
Edit: Sorry, but how would you get the input function to work in a text message? Like naming your character?
Edit: Sorry, but how would you get the input function to work in a text message? Like naming your character?
- 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)
Update to Messenger 1.3Forestofmyown wrote: ↑Tue Jan 01, 2019 6:47 pm Thank you! That's great!
Edit: Sorry, but how would you get the input function to work in a text message? Like naming your character?
Input function for name
$ msg(None, name_input=True)
GitHub
- Attachments
-
- messenger 1.3.zip
- (8.15 MiB) Downloaded 64 times
Re: telegram messenger (2 version)
Re: telegram messenger (2 version)
Thank you SO much for this code!sDextra wrote: ↑Wed Jan 02, 2019 3:30 amUpdate to Messenger 1.3Forestofmyown wrote: ↑Tue Jan 01, 2019 6:47 pm Thank you! That's great!
Edit: Sorry, but how would you get the input function to work in a text message? Like naming your character?
Input function for name
$ msg(None, name_input=True)
GitHub
Sorry to bother you again
But is it possible to "attach" the avatar to the "who"?
Because in my game I let the player name all the characters.
So this part won't work for me at all.
Code: Select all
self.avatar = 'messenger/av/'+name.lower().replace(' ', '_')+'.png'
So whatever the person names the character it won't conflict.
I still get confused with those def codes, so I don't really know how to "adjust" that part.
Thank you so much. Have a good year
- 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)
Nanahs wrote: ↑Wed Jan 02, 2019 11:25 amThank you SO much for this code!sDextra wrote: ↑Wed Jan 02, 2019 3:30 amUpdate to Messenger 1.3Forestofmyown wrote: ↑Tue Jan 01, 2019 6:47 pm Thank you! That's great!
Edit: Sorry, but how would you get the input function to work in a text message? Like naming your character?
Input function for name
$ msg(None, name_input=True)
GitHub
Sorry to bother you again
But is it possible to "attach" the avatar to the "who"?
Because in my game I let the player name all the characters.
So this part won't work for me at all.
A code that would be like: who1.avatar='avatar1.png'Code: Select all
self.avatar = 'messenger/av/'+name.lower().replace(' ', '_')+'.png'
So whatever the person names the character it won't conflict.
I still get confused with those def codes, so I don't really know how to "adjust" that part.
Thank you so much. Have a good year
Code: Select all
self.avatar = 'messenger/av/'+name.lower().replace(' ', '_')+'.png'
1. If you do not use group chat:
Code: Select all
add 'messenger/av/'+interlocutor_name.lower().replace(' ', '_')+'.png' pos (67,25)
2. If you use group chat:
For Characters:
Code: Select all
self.avatar ='messenger/groupchat/'+name.lower().replace(' ', '_')+'.png'
Code: Select all
groupchat.add( Interlocutor(ID=1, name='Nanahs', color='#d6ff60') ) ]
Re: telegram messenger (2 version)
Oh, ok. It's because I have 6 characters on my game. And I let the player choose all the names. Like this:sDextra wrote: ↑Wed Jan 02, 2019 12:11 pmNanahs wrote: ↑Wed Jan 02, 2019 11:25 amThank you SO much for this code!
Sorry to bother you again
But is it possible to "attach" the avatar to the "who"?
Because in my game I let the player name all the characters.
So this part won't work for me at all.
A code that would be like: who1.avatar='avatar1.png'Code: Select all
self.avatar = 'messenger/av/'+name.lower().replace(' ', '_')+'.png'
So whatever the person names the character it won't conflict.
I still get confused with those def codes, so I don't really know how to "adjust" that part.
Thank you so much. Have a good yearHm, this avatar is for group chat, not for charactersCode: Select all
self.avatar = 'messenger/av/'+name.lower().replace(' ', '_')+'.png'
1. If you do not use group chat:Instead of "interlocutor_name" you can use your variable or functionCode: Select all
add 'messenger/av/'+interlocutor_name.lower().replace(' ', '_')+'.png' pos (67,25)
2. If you use group chat:
For Characters:If you named your character 'Nanahs', then the path to the avatar: 'messenger/groupchat/nanahs.png'Code: Select all
self.avatar ='messenger/groupchat/'+name.lower().replace(' ', '_')+'.png'
Have I understood you correctly? I hope I could explainCode: Select all
groupchat.add( Interlocutor(ID=1, name='Nanahs', color='#d6ff60') ) ]
Code: Select all
default character1 = ""
default character2 = ""
default character3 = ""
default character4 = ""
default character5 = ""
while character1 == "":
$ character1 = renpy.input("Give her a name.").strip()
So I tried:
Code: Select all
$ groupchat_enable = True
$ groupchat = GroupChat(name='Chat') # Group Chat Name
$ groupchat.add( Interlocutor(ID=1, name='[Character1]', color='#fff68f') ) # Interlocutor 1
$ groupchat.add( Interlocutor(ID=2, name='[Character2]', color='#b73b87') ) # Interlocutor 2
$ groupchat.add( Interlocutor(ID=3, name='[Character3]', color='#009999') ) # Interlocutor 3
$ groupchat.add( Interlocutor(ID=4, name='[Character4]', color='#d6ff60') ) # Interlocutor 4
$ active_groupchat = groupchat # Set Active Group Chat
That's why I thought if there was another way. Since each interlocutor is "who1" "who2", etc, I was wondering if we could "attach" the avatar to the "who". So it wouldn't matter the name the person chose.
- 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)
There is another way.Nanahs wrote: ↑Wed Jan 02, 2019 2:32 pmOh, ok. It's because I have 6 characters on my game. And I let the player choose all the names. Like this:sDextra wrote: ↑Wed Jan 02, 2019 12:11 pmNanahs wrote: ↑Wed Jan 02, 2019 11:25 am
Thank you SO much for this code!
Sorry to bother you again
But is it possible to "attach" the avatar to the "who"?
Because in my game I let the player name all the characters.
So this part won't work for me at all.
A code that would be like: who1.avatar='avatar1.png'Code: Select all
self.avatar = 'messenger/av/'+name.lower().replace(' ', '_')+'.png'
So whatever the person names the character it won't conflict.
I still get confused with those def codes, so I don't really know how to "adjust" that part.
Thank you so much. Have a good yearHm, this avatar is for group chat, not for charactersCode: Select all
self.avatar = 'messenger/av/'+name.lower().replace(' ', '_')+'.png'
1. If you do not use group chat:Instead of "interlocutor_name" you can use your variable or functionCode: Select all
add 'messenger/av/'+interlocutor_name.lower().replace(' ', '_')+'.png' pos (67,25)
2. If you use group chat:
For Characters:If you named your character 'Nanahs', then the path to the avatar: 'messenger/groupchat/nanahs.png'Code: Select all
self.avatar ='messenger/groupchat/'+name.lower().replace(' ', '_')+'.png'
Have I understood you correctly? I hope I could explainCode: Select all
groupchat.add( Interlocutor(ID=1, name='Nanahs', color='#d6ff60') ) ]
And I wanted to add them on the group chat. And the chat member names would be the names the player chose.Code: Select all
default character1 = "" default character2 = "" default character3 = "" default character4 = "" default character5 = "" while character1 == "": $ character1 = renpy.input("Give her a name.").strip()
So I tried:
But that way the game don't recognize the avatars.Code: Select all
$ groupchat_enable = True $ groupchat = GroupChat(name='Chat') # Group Chat Name $ groupchat.add( Interlocutor(ID=1, name='[Character1]', color='#fff68f') ) # Interlocutor 1 $ groupchat.add( Interlocutor(ID=2, name='[Character2]', color='#b73b87') ) # Interlocutor 2 $ groupchat.add( Interlocutor(ID=3, name='[Character3]', color='#009999') ) # Interlocutor 3 $ groupchat.add( Interlocutor(ID=4, name='[Character4]', color='#d6ff60') ) # Interlocutor 4 $ active_groupchat = groupchat # Set Active Group Chat
That's why I thought if there was another way. Since each interlocutor is "who1" "who2", etc, I was wondering if we could "attach" the avatar to the "who". So it wouldn't matter the name the person chose.
Code: Select all
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'
Code: Select all
$ groupchat.add( Interlocutor(ID=1, name=character1, avatar='avatar_name', color='#b73b87') )
Re: telegram messenger (2 version)
Thank you SOOO much sDextra! I'll try that
Re: telegram messenger (2 version)
Sorry to bother again, but how do I make the messenger (the one with group chat) stay in the middle of the screen?
- 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)
Code: Select all
#images.rpy
transform move_messenger(t=1.0):
xalign .9 yalign .5
on show:
xalign 1.5
easein t xalign .9
on hide:
easeout t xalign 1.5
alpha 0
If you don't need movement:
Code: Select all
transform move_messenger:
xalign .5 yalign .5
Re: telegram messenger (2 version)
Thank you so much!sDextra wrote: ↑Fri Jan 04, 2019 8:01 amThe default is 'xalign .9', you can replace with 'xalign .5'Code: Select all
#images.rpy transform move_messenger(t=1.0): xalign .9 yalign .5 on show: xalign 1.5 easein t xalign .9 on hide: easeout t xalign 1.5 alpha 0
If you don't need movement:Code: Select all
transform move_messenger: xalign .5 yalign .5
Re: telegram messenger (2 version)
Sorry to bother you for the 100000000th time
But is it possible to add that function that opens the image when you click on it + the time the message was sent/received, to the older messenger code? Only this two things.
It's because I had already edited many labels and pictures according to the older version, and their not working well with the newer one.
This one:
I'm sorry if it's a lot of work or if you can't do it/don't have time to do it.
And thank you so much for all of your codes.
But is it possible to add that function that opens the image when you click on it + the time the message was sent/received, to the older messenger code? Only this two things.
It's because I had already edited many labels and pictures according to the older version, and their not working well with the newer one.
This one:
Code: Select all
#################################################################################
### Telegram Messenger
#################################################################################
init python:
### Цветовая схема
style_button_back = "#282E33"
style_button_hovr = "#5F6C77"
style_button_inst = "#14171A"
# Стиль кнопок
style.btn = Style(style.default)
style.btn.background = style_button_back
style.btn.hover_background = style_button_hovr
style.btn.insensitive_background = style_button_inst
# Стиль ползунка
style.bar_vert = Style(style.default)
style.bar_vert.right_bar = style_button_inst
style.bar_vert.left_bar = style_button_inst
style.bar_vert.thumb = style_button_hovr
style.bar_vert.bar_vertical = True
style.bar_vert.bar_invert = True
style.bar_vert.xalign = 1.0
style.bar_vert.yalign = 0.6
style.bar_vert.xsize = 10
style.bar_vert.ysize = 780
# Стиль текста
style.txt_base = Style(style.default)
style.txt_base.font = "gui/tahoma.ttf"
style.txt_base.xalign = 0.5
style.txt_base.yalign = 0.5
style.txt_base.size = 30
style.txt_base.color = "#fff"
yadj = ui.adjustment()
# Добавление нового сообщения
def msg(txt, who=False, sound=False):
store.m_msg.append((who, txt, sound))
store.yadj.value = store.yadj.range+300
renpy.restart_interaction()
if who:
renpy.play("new_message.mp3", "sound")
renpy.pause()
# Удаление последнего сообщения
def del_last_msg():
if len(store.m_msg) > 0:
del store.m_msg[-1]
# Удаление всех сообщений
def del_all_msg():
store.m_msg = []
#################################################################################
# Экран сообщения
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"
#################################################################################
#################################################################################
# by sDextra
# old Sota
#################################################################################
And thank you so much for all of your codes.
- 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)
I'm not sure about the sound player, but try this code.Nanahs wrote: ↑Wed Jan 09, 2019 7:59 pm Sorry to bother you for the 100000000th time
But is it possible to add that function that opens the image when you click on it + the time the message was sent/received, to the older messenger code? Only this two things.
It's because I had already edited many labels and pictures according to the older version, and their not working well with the newer one.
Code: Select all
#################################################################################
### Telegram Messenger
#################################################################################
init:
transform move_pic(t=.5):
xalign .5 yalign .5
on show:
yalign -2.0
easein t yalign .5
on hide:
easeout t yalign -2.0
alpha 0
init python:
display_aspect_ratio = 16.0 / 9.0
### Color Scheme
style_button_back = "#282E33"
style_button_hovr = "#5F6C77"
style_button_inst = "#14171A"
# Button Style
style.btn = Style(style.default)
style.btn.background = style_button_back
style.btn.hover_background = style_button_hovr
style.btn.insensitive_background = style_button_inst
# Bar Style
style.bar_vert = Style(style.default)
style.bar_vert.right_bar = style_button_inst
style.bar_vert.left_bar = style_button_inst
style.bar_vert.thumb = style_button_hovr
style.bar_vert.bar_vertical = True
style.bar_vert.bar_invert = True
style.bar_vert.xalign = 1.0
style.bar_vert.yalign = 0.6
style.bar_vert.xsize = 10
style.bar_vert.ysize = 780
# Text Style
style.txt_base = Style(style.default)
style.txt_base.font = "gui/tahoma.ttf"
style.txt_base.xalign = 0.5
style.txt_base.yalign = 0.5
style.txt_base.size = 30
style.txt_base.color = "#fff"
# Time Style
style.txt_time = Style(style.txt_base)
style.txt_time.align = (1.0,.98)
style.txt_time.xanchor = 1.0
yadj = ui.adjustment()
# New Message
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()
# Удаление последнего сообщения
def del_last_msg():
if len(store.m_msg) > 0:
del store.m_msg[-1]
# Удаление всех сообщений
def del_all_msg():
store.m_msg = []
from datetime import datetime
def get_current_time():
now = datetime.now()
time = datetime.strftime(now, "%H:%M")
return time
def time_update(m=1):
if type(message_time) != bool:
hours, minutes = message_time
if minutes + m >= 60:
hours += 1
if hours >= 24:
hours = 0
minutes += m-60
else:
minutes += m
store.message_time = [hours, minutes]
# Message Time Tag
def time_tag(tag, argument, contents):
size = 18
color = store.style_gray
return [ (renpy.TEXT_TAG, u"size={}".format(size)), (renpy.TEXT_TAG, u"color={}".format(color)),
] + contents + [ (renpy.TEXT_TAG, u"/size"), (renpy.TEXT_TAG, u"/color"), ]
config.custom_text_tags["t"] = time_tag
# TIME
message_time = [9,40]
message_time_current = False # if True - current time from pc
image box = Frame("messenger/box.png", 25, 25)
image h_box = Frame( im.MatrixColor("messenger/box.png", im.matrix.brightness(.05)), 25, 25)
#################################################################################
# Messenger Screen
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, pic, hm = message
$ xgn = 0.0 if who else 1.0
$ xpic = 380
if sound:
hbox spacing -60 xalign xgn:
imagebutton auto "messenger/sound_%s.png" xalign xgn action Play("sound", sound)
if hm:
text "{t}%s{/t}"%(hm) style 'txt_time'
elif pic:
hbox spacing -60 xalign xgn:
button xalign xgn xmaximum 580 xpadding 0 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 (xpic, xpic/display_aspect_ratio)
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'
# Name
text "%s"%(msg_name) style "txt_base" size 35 xalign 0.31 xanchor 0.0 yalign 0.04
# Avatar
add "messenger/av/"+msg_name.lower().replace(' ', '_')+".png" pos (100,27)
# Arrow
imagebutton auto "messenger/arr_%s.png" pos (10, 33) action NullAction()
# Delete
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)
# Bar
vbar value YScrollValue("vp_msg") style "bar_vert"
#################################################################################
screen full_pic(pic=False):
modal True
button background None action Hide('full_pic')
if pic:
add '#00000090'
add 'messenger/pic/%s.jpg'%(pic) align .5,.5 at move_pic
#################################################################################
# by sDextra
# old Sota
#################################################################################
Re: telegram messenger (2 version)
Thank you SO much! I've been trying to add the time thing for a long time.sDextra wrote: ↑Wed Jan 09, 2019 10:39 pmI'm not sure about the sound player, but try this code.Nanahs wrote: ↑Wed Jan 09, 2019 7:59 pm Sorry to bother you for the 100000000th time
But is it possible to add that function that opens the image when you click on it + the time the message was sent/received, to the older messenger code? Only this two things.
It's because I had already edited many labels and pictures according to the older version, and their not working well with the newer one.
Code: Select all
################################################################################# ### Telegram Messenger ################################################################################# init: transform move_pic(t=.5): xalign .5 yalign .5 on show: yalign -2.0 easein t yalign .5 on hide: easeout t yalign -2.0 alpha 0 init python: display_aspect_ratio = 16.0 / 9.0 ### Color Scheme style_button_back = "#282E33" style_button_hovr = "#5F6C77" style_button_inst = "#14171A" # Button Style style.btn = Style(style.default) style.btn.background = style_button_back style.btn.hover_background = style_button_hovr style.btn.insensitive_background = style_button_inst # Bar Style style.bar_vert = Style(style.default) style.bar_vert.right_bar = style_button_inst style.bar_vert.left_bar = style_button_inst style.bar_vert.thumb = style_button_hovr style.bar_vert.bar_vertical = True style.bar_vert.bar_invert = True style.bar_vert.xalign = 1.0 style.bar_vert.yalign = 0.6 style.bar_vert.xsize = 10 style.bar_vert.ysize = 780 # Text Style style.txt_base = Style(style.default) style.txt_base.font = "gui/tahoma.ttf" style.txt_base.xalign = 0.5 style.txt_base.yalign = 0.5 style.txt_base.size = 30 style.txt_base.color = "#fff" # Time Style style.txt_time = Style(style.txt_base) style.txt_time.align = (1.0,.98) style.txt_time.xanchor = 1.0 yadj = ui.adjustment() # New Message 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() # Удаление последнего сообщения def del_last_msg(): if len(store.m_msg) > 0: del store.m_msg[-1] # Удаление всех сообщений def del_all_msg(): store.m_msg = [] from datetime import datetime def get_current_time(): now = datetime.now() time = datetime.strftime(now, "%H:%M") return time def time_update(m=1): if type(message_time) != bool: hours, minutes = message_time if minutes + m >= 60: hours += 1 if hours >= 24: hours = 0 minutes += m-60 else: minutes += m store.message_time = [hours, minutes] # Message Time Tag def time_tag(tag, argument, contents): size = 18 color = store.style_gray return [ (renpy.TEXT_TAG, u"size={}".format(size)), (renpy.TEXT_TAG, u"color={}".format(color)), ] + contents + [ (renpy.TEXT_TAG, u"/size"), (renpy.TEXT_TAG, u"/color"), ] config.custom_text_tags["t"] = time_tag # TIME message_time = [9,40] message_time_current = False # if True - current time from pc image box = Frame("messenger/box.png", 25, 25) image h_box = Frame( im.MatrixColor("messenger/box.png", im.matrix.brightness(.05)), 25, 25) ################################################################################# # Messenger Screen 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, pic, hm = message $ xgn = 0.0 if who else 1.0 $ xpic = 380 if sound: hbox spacing -60 xalign xgn: imagebutton auto "messenger/sound_%s.png" xalign xgn action Play("sound", sound) if hm: text "{t}%s{/t}"%(hm) style 'txt_time' elif pic: hbox spacing -60 xalign xgn: button xalign xgn xmaximum 580 xpadding 0 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 (xpic, xpic/display_aspect_ratio) 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' # Name text "%s"%(msg_name) style "txt_base" size 35 xalign 0.31 xanchor 0.0 yalign 0.04 # Avatar add "messenger/av/"+msg_name.lower().replace(' ', '_')+".png" pos (100,27) # Arrow imagebutton auto "messenger/arr_%s.png" pos (10, 33) action NullAction() # Delete 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) # Bar vbar value YScrollValue("vp_msg") style "bar_vert" ################################################################################# screen full_pic(pic=False): modal True button background None action Hide('full_pic') if pic: add '#00000090' add 'messenger/pic/%s.jpg'%(pic) align .5,.5 at move_pic ################################################################################# # by sDextra # old Sota #################################################################################
But it game me this error:
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 445, in script
$renpy.pause (delay=1.0, hard=True)
File "game/script.rpy", line 445, in <module>
$renpy.pause (delay=1.0, hard=True)
File "game/messenger.rpy", line 109, in execute
screen telegram():
File "game/messenger.rpy", line 109, in execute
screen telegram():
File "game/messenger.rpy", line 110, in execute
frame background "messenger/back.png" xysize (600,975) align (0.9,.5):
File "game/messenger.rpy", line 138, in execute
text "%s"%(msg_name) style "txt_base" size 35 xalign 0.31 xanchor 0.0 yalign 0.04
NameError: name 'msg_name' is not defined
- 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)
'msg_name' is just interlocutor's name. In new version it is 'active.name'.Nanahs wrote: ↑Thu Jan 10, 2019 7:14 amThank you SO much! I've been trying to add the time thing for a long time.sDextra wrote: ↑Wed Jan 09, 2019 10:39 pmI'm not sure about the sound player, but try this code.Nanahs wrote: ↑Wed Jan 09, 2019 7:59 pm Sorry to bother you for the 100000000th time
But is it possible to add that function that opens the image when you click on it + the time the message was sent/received, to the older messenger code? Only this two things.
It's because I had already edited many labels and pictures according to the older version, and their not working well with the newer one.
Code: Select all
################################################################################# ### Telegram Messenger ################################################################################# init: transform move_pic(t=.5): xalign .5 yalign .5 on show: yalign -2.0 easein t yalign .5 on hide: easeout t yalign -2.0 alpha 0 init python: display_aspect_ratio = 16.0 / 9.0 ### Color Scheme style_button_back = "#282E33" style_button_hovr = "#5F6C77" style_button_inst = "#14171A" # Button Style style.btn = Style(style.default) style.btn.background = style_button_back style.btn.hover_background = style_button_hovr style.btn.insensitive_background = style_button_inst # Bar Style style.bar_vert = Style(style.default) style.bar_vert.right_bar = style_button_inst style.bar_vert.left_bar = style_button_inst style.bar_vert.thumb = style_button_hovr style.bar_vert.bar_vertical = True style.bar_vert.bar_invert = True style.bar_vert.xalign = 1.0 style.bar_vert.yalign = 0.6 style.bar_vert.xsize = 10 style.bar_vert.ysize = 780 # Text Style style.txt_base = Style(style.default) style.txt_base.font = "gui/tahoma.ttf" style.txt_base.xalign = 0.5 style.txt_base.yalign = 0.5 style.txt_base.size = 30 style.txt_base.color = "#fff" # Time Style style.txt_time = Style(style.txt_base) style.txt_time.align = (1.0,.98) style.txt_time.xanchor = 1.0 yadj = ui.adjustment() # New Message 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() # Удаление последнего сообщения def del_last_msg(): if len(store.m_msg) > 0: del store.m_msg[-1] # Удаление всех сообщений def del_all_msg(): store.m_msg = [] from datetime import datetime def get_current_time(): now = datetime.now() time = datetime.strftime(now, "%H:%M") return time def time_update(m=1): if type(message_time) != bool: hours, minutes = message_time if minutes + m >= 60: hours += 1 if hours >= 24: hours = 0 minutes += m-60 else: minutes += m store.message_time = [hours, minutes] # Message Time Tag def time_tag(tag, argument, contents): size = 18 color = store.style_gray return [ (renpy.TEXT_TAG, u"size={}".format(size)), (renpy.TEXT_TAG, u"color={}".format(color)), ] + contents + [ (renpy.TEXT_TAG, u"/size"), (renpy.TEXT_TAG, u"/color"), ] config.custom_text_tags["t"] = time_tag # TIME message_time = [9,40] message_time_current = False # if True - current time from pc image box = Frame("messenger/box.png", 25, 25) image h_box = Frame( im.MatrixColor("messenger/box.png", im.matrix.brightness(.05)), 25, 25) ################################################################################# # Messenger Screen 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, pic, hm = message $ xgn = 0.0 if who else 1.0 $ xpic = 380 if sound: hbox spacing -60 xalign xgn: imagebutton auto "messenger/sound_%s.png" xalign xgn action Play("sound", sound) if hm: text "{t}%s{/t}"%(hm) style 'txt_time' elif pic: hbox spacing -60 xalign xgn: button xalign xgn xmaximum 580 xpadding 0 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 (xpic, xpic/display_aspect_ratio) 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' # Name text "%s"%(msg_name) style "txt_base" size 35 xalign 0.31 xanchor 0.0 yalign 0.04 # Avatar add "messenger/av/"+msg_name.lower().replace(' ', '_')+".png" pos (100,27) # Arrow imagebutton auto "messenger/arr_%s.png" pos (10, 33) action NullAction() # Delete 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) # Bar vbar value YScrollValue("vp_msg") style "bar_vert" ################################################################################# screen full_pic(pic=False): modal True button background None action Hide('full_pic') if pic: add '#00000090' add 'messenger/pic/%s.jpg'%(pic) align .5,.5 at move_pic ################################################################################# # by sDextra # old Sota #################################################################################
But it game me this error:
It's the 'msg_name' thing, right?Code: Select all
I'm sorry, but an uncaught exception occurred. While running game code: File "game/script.rpy", line 445, in script $renpy.pause (delay=1.0, hard=True) File "game/script.rpy", line 445, in <module> $renpy.pause (delay=1.0, hard=True) File "game/messenger.rpy", line 109, in execute screen telegram(): File "game/messenger.rpy", line 109, in execute screen telegram(): File "game/messenger.rpy", line 110, in execute frame background "messenger/back.png" xysize (600,975) align (0.9,.5): File "game/messenger.rpy", line 138, in execute text "%s"%(msg_name) style "txt_base" size 35 xalign 0.31 xanchor 0.0 yalign 0.04 NameError: name 'msg_name' is not defined
$ msg_name = 'Nanahs'
Who is online
Users browsing this forum: No registered users