Basic Message System

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
cotton
Newbie
Posts: 1
Joined: Tue Dec 24, 2013 3:38 am
Contact:

Re: Basic Message System

#31 Post by cotton »

Thank you very much for sharing this!!
I was wondering if there's a way to make the area for the message and the links to the message be separate screens?

User avatar
saguaro
Miko-Class Veteran
Posts: 560
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Organization: Lucky Special Games
itch: saguarofoo
Location: USA
Contact:

Re: Basic Message System

#32 Post by saguaro »

Probably what you want is to put them in different types of containers (hbox, vbox) or change the styling. Check out screen language and style properties in the documentation.

User avatar
balldancing
Regular
Posts: 65
Joined: Tue Sep 03, 2013 9:32 am
Location: milan
Contact:

Re: Basic Message System

#33 Post by balldancing »

Hi there!! This is absolutely perfect and a dream come true.
A few questions if you don't mind ^^ I used the basic in-message system before this and I'm really bad with coding, but to achieve this kind of layout for my inbox, I defined styles and then changed the style values to shape and shop the whole thing with this:

Code: Select all

    style.messageWindow = Style(style.window)
    style.messageColumns = Style(style.hbox)
    style.messageListBox = Style(style.vbox)
    style.messageListViewport = Style(style.viewport)
    style.messageButton = Style(style.button)
    style.messageButtonText = Style(style.button_text)
    style.messageScrollBar = Style(style.vscrollbar)
    style.messageBodyScrollBar = Style(style.vscrollbar)
    style.messageBodyBox = Style(style.vbox)
    style.messageBodyViewport = Style(style.viewport)
    style.messageText = Style(style.say_dialogue)
    style.messageControls = Style(style.hbox)
I understand there are styles at the bottom of messages.rpy, but they're a bit vague and I can't seem to piece the styles together with the coding like I did with the other... I really would like to achieve the layout I linked earlier but with this messaging system because the reply idea is really neat *-*
Image
I offer proofreading and editing services~

storymasterq
Newbie
Posts: 12
Joined: Mon May 19, 2014 10:45 pm
Contact:

Re: Basic Message System

#34 Post by storymasterq »

Hi,

Is there a way to incorporate some sort contact list? I want to be able to add some senders to the list and be able to compose new messages to said contacts. Would it be too hard and/or complex?

User avatar
saguaro
Miko-Class Veteran
Posts: 560
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Organization: Lucky Special Games
itch: saguarofoo
Location: USA
Contact:

Re: Basic Message System

#35 Post by saguaro »

I thought others might also be interested in that feature so I updated the system with a draft feature and I added the queue and a few other things while I was at it. I hope that helps.

storymasterq
Newbie
Posts: 12
Joined: Mon May 19, 2014 10:45 pm
Contact:

Re: Basic Message System

#36 Post by storymasterq »

Awesome! I'll look into it right now.
Meanwhile, I tinkered with the code to add a delete confirmation. Do you think it'd be a good way to do it like so?

Code: Select all

screen mailbox_commands:
    hbox:
...
        if current_message:
            textbutton "Delete" action [Show("yesno_prompt",message="Delete message?",yes_action=current_message.delete,Hide("yesno_prompt")],no_action=Hide("yesno_prompt")), SetScreenVariable("current_message", None)]
I'm trying to learn to code Ren'Py, and by extension, Python. I tried this and it works, but perhaps there's a better way to go about it?

User avatar
saguaro
Miko-Class Veteran
Posts: 560
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Organization: Lucky Special Games
itch: saguarofoo
Location: USA
Contact:

Re: Basic Message System

#37 Post by saguaro »

The only other way I can think of would be to make a custom popup, which is only really necessary if you need the confirmation to be styled differently than the yes/no screen.

storymasterq
Newbie
Posts: 12
Joined: Mon May 19, 2014 10:45 pm
Contact:

Re: Basic Message System

#38 Post by storymasterq »

Hmm, custom popup. I'll probably try it this weekend.

Can you tell me why I can't send current_message.subject into yesno_prompt's message?

Code: Select all

Show("yesno_prompt",message="Delete [current_message.subject]?",yes_action=current_message.delete,Hide("yesno_prompt")
This fails with a weird, weird error which I don't have on hand. I discarded the idea and just went with "Delete message".

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Basic Message System

#39 Post by Asceai »

storymasterq wrote:Hmm, custom popup. I'll probably try it this weekend.

Can you tell me why I can't send current_message.subject into yesno_prompt's message?

Code: Select all

Show("yesno_prompt",message="Delete [current_message.subject]?",yes_action=current_message.delete,Hide("yesno_prompt")
This fails with a weird, weird error which I don't have on hand. I discarded the idea and just went with "Delete message".
Yeah, no dots in renpy substitution. Don't use renpy substitution, use python substitution
"Delete %s?" % current_message.subject

storymasterq
Newbie
Posts: 12
Joined: Mon May 19, 2014 10:45 pm
Contact:

Re: Basic Message System

#40 Post by storymasterq »

Oh, yay! Knowledge! Thanks, Asceai!
Proofreading for Free - here - Current project(s): None

Currently working on: My first VN, a futuristic slice-of-life with a hint of romance.

storymasterq
Newbie
Posts: 12
Joined: Mon May 19, 2014 10:45 pm
Contact:

Re: Basic Message System

#41 Post by storymasterq »

Me again, sorry for double posting.

I wanted to ask you to do this for me, but I found it to be such good programming practice, I did it myself :D
Here's a little addition to the Messaging system, Attachments!

Code: Select all

        def __init__(self, subject, sender, body, reply_label=False, delay=False, view=True, read=False, attach=False):
...
            self.read = read
            self.attach = attach
...

Code: Select all

    def add_message(subject, sender, body, reply_label=False, delay=False, attach=False):
        message = Mail(subject, sender, body, reply_label, delay, attach=attach)
I also added a little space between the mail header and body, just to see it better.

Code: Select all

...
                        if current_message:
                            vbox spacing 10:
                                vbox:
                                    text ("From: " + current_message.sender)
                                    text ("Subject: " + current_message.subject)
                                    if current_message.attach:
                                        hbox xalign 0 spacing 10:
                                            text ("Attachment: ") 
                                            textbutton (current_message.attach[0]) action Jump(current_message.attach[1])
                                text current_message.body
                vbar value YScrollValue("view_message")
            use mailbox_commands
The attachment is a tuple of "Attachment text", such as "NotVirus.exe", and "Label_text", which is where Ren'Py should jump to upon clicking the attachment. So, usage would be something like this

Code: Select all

    add_message("Needs something enlarged?", "Penlargement", "Get yourself some woo, hoo", attach=["NotVirus.exe","attach_notvirus"])
So, what do you think? :mrgreen:
Proofreading for Free - here - Current project(s): None

Currently working on: My first VN, a futuristic slice-of-life with a hint of romance.

User avatar
saguaro
Miko-Class Veteran
Posts: 560
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Organization: Lucky Special Games
itch: saguarofoo
Location: USA
Contact:

Re: Basic Message System

#42 Post by saguaro »

For broader usage, two things I would consider are the jump action and modal.

Once the player jumps to a label, how do they get back to where they were in the script? The inbox is a modal screen, so once they click the attachment... what happens? In the case of a virus-type attachment that is supposed to mess with the screen, we can manually hide the mailbox in the label, but what about an attachment of a image or a text document, for example?

So I guess the question is if you'd like people to be able to attach different "types" of attachments.

storymasterq
Newbie
Posts: 12
Joined: Mon May 19, 2014 10:45 pm
Contact:

Re: Basic Message System

#43 Post by storymasterq »

Hmm, alright, so something to the effect of call_in_new_context with a return, then?

Attachments of images or text should be handled by the called label, either by displaying the image or narrating the text.
Proofreading for Free - here - Current project(s): None

Currently working on: My first VN, a futuristic slice-of-life with a hint of romance.

pkeros
Newbie
Posts: 1
Joined: Sun Jul 06, 2014 11:16 pm
Contact:

Re: Basic Message System

#44 Post by pkeros »

First of all, I really like this new message system. I've been using the old one for a while, and this one works much better overall.

I'm trying to implement a "Refresh" button. That is, you click the button, and it adds new messages. The idea here is to add a few more messages with each refresh, allowing an email conversation to develop slowly. I'm trying to use the "add_now" function to do it, but it's not working too great. I don't want to have to exit out of the inbox and advance the main text each time I want to add more messages. Alternatively, if there's a way to add messages instantly after I use the Exit button, I can make that work.

Any tips on how to approach this? Thanks!

User avatar
Tayruu
Regular
Posts: 141
Joined: Sat Jul 05, 2014 7:57 pm

Re: Basic Message System

#45 Post by Tayruu »

I've discovered that if you open a message longer than the message viewport, scroll to the bottom, then view another message that's also long, the viewport will remain scrolled down instead of reset to the top.

I can't seem to work out how to do it myself. I thought SetVariable("view_message.viewport.top", 0) might do it, or anything to do with viewport.y/viewport.top, any ideas?

Post Reply

Who is online

Users browsing this forum: No registered users