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
User avatar
balldancing
Regular
Posts: 65
Joined: Tue Sep 03, 2013 9:32 am
Location: milan
Contact:

Re: Basic Message System

#46 Post by balldancing » Fri Aug 01, 2014 12:59 am

I got this error message when trying out the demo script

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/messages.rpy", line 111: expected a keyword argument, colon, or end of line.
    textbutton "Mailbox (%d New)" % (new_message_count()) action Show("mailbox")
                                  ^

File "game/messages.rpy", line 125: expected a keyword argument, colon, or end of line.
    text ("Messages: %d (%d unread)") % (message_count(), new_message_count())
                                      ^

File "game/messages.rpy", line 179: u'xsize' is not a keyword argument or valid child for the frame statement.
    xsize 200
         ^
Not sure what to do ><
Image
I offer proofreading and editing services~

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Basic Message System

#47 Post by xela » Fri Aug 01, 2014 2:55 am

balldancing wrote:File "game/messages.rpy", line 111: expected a keyword argument, colon, or end of line.
textbutton "Mailbox (%d New)" % (new_message_count()) action Show("mailbox")
^

Code: Select all

textbutton ("Mailbox (%d New)" % new_message_count()) action Show("mailbox")
Try this for all three buttons.
Like what we're doing? Support us at:
Image

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

Re: Basic Message System

#48 Post by balldancing » Fri Aug 01, 2014 4:25 am

xela wrote:
balldancing wrote:File "game/messages.rpy", line 111: expected a keyword argument, colon, or end of line.
textbutton "Mailbox (%d New)" % (new_message_count()) action Show("mailbox")
^

Code: Select all

textbutton ("Mailbox (%d New)" % new_message_count()) action Show("mailbox")
Try this for all three buttons.
I corrected:

Code: Select all

        if new_message_count() > 0:
            textbutton ("Mailbox (%d New)" % new_message_count()) action Show("mailbox")
and

Code: Select all

            if new_message_count() > 0:
                text ("Messages: %d (%d unread)" % message_count(), new_message_count())
            else:
                text ("Messages: %d" % message_count())
The only error now is the xsize error (thanks for the first two though ^^)

---------------
*EDIT*
although those codes aren't enough arguments for the string....... OTL
Image
I offer proofreading and editing services~

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Basic Message System

#49 Post by xela » Fri Aug 01, 2014 7:45 am

Last version of renpy would have sold of those issues... in any case, old way of writing xsize is:

Code: Select all

xminimum 200
xmaximum 200
Like what we're doing? Support us at:
Image

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

Re: Basic Message System

#50 Post by balldancing » Fri Aug 01, 2014 8:13 am

xela wrote:Last version of renpy would have sold of those issues... in any case, old way of writing xsize is:

Code: Select all

xminimum 200
xmaximum 200
oh do i have to update renpy? ><' (thanks also!)
Image
I offer proofreading and editing services~

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Basic Message System

#51 Post by xela » Fri Aug 01, 2014 8:17 am

balldancing wrote:oh do i have to update renpy? ><' (thanks also!)
Unless there is a mad axeman standing over you threatening to cut off your head, you don't really "have" to :)

But you never the less should, it will make sure that all of the recent code is working without you having to adapt. You problems are due to outdated version, not mistakes in proposed code.
Like what we're doing? Support us at:
Image

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

Re: Basic Message System

#52 Post by balldancing » Fri Aug 01, 2014 8:29 am

xela wrote:
balldancing wrote:oh do i have to update renpy? ><' (thanks also!)
Unless there is a mad axeman standing over you threatening to cut off your head, you don't really "have" to :)

But you never the less should, it will make sure that all of the recent code is working without you having to adapt. You problems are due to outdated version, not mistakes in proposed code.
I'M SO EMBARASSED AHHH i was so long due for an update OTL thank you for shedding light on my forgetfulness (much love from me and eileen and the crazy axeman)
Image
I offer proofreading and editing services~

Ryu-Kun
Newbie
Posts: 3
Joined: Sat May 24, 2014 9:11 pm
Contact:

Re: Basic Message System

#53 Post by Ryu-Kun » Mon Aug 04, 2014 10:41 am

All right man, this is a really cool feature! I can imagine how long it would've took to code all of this!
Now here's my question!
Is it possible to change the Menu with a image file?
Looking at "Message.rpy" I see how to change it, but you have to manually assign everything in align with the X and Y axis! What I want it to have the same screen, but on a phone, or something similar to that. I know you can do it with the menu in "Screens.rpy"!

(Basically, just put the messages on a phone, like this one: Image)

User avatar
MindlessLogic
Newbie
Posts: 5
Joined: Mon Feb 03, 2014 7:44 pm
Contact:

Re: Basic Message System

#54 Post by MindlessLogic » Sun Aug 31, 2014 4:35 pm

Beautiful bit of code; thank you for sharing it! :D

I've been playing around with the system for a few hours, and I noticed the blue frame surrounding draft/reply messages no longer shows up. I've re-downloaded messages.rpy, but there doesn't seem to be anything I've deleted.

How do you get the vbox frame to appear around the choices menu?

Choice code:

Code: Select all

screen choice:

    if reply_screen or draft_screen:
        # this is the menu for message replies and drafts
        frame:
            style_group "mailbox"

            vbox:
                label "Draft"
                if reply_screen:
                    text ("To: " + current_message.sender)                
                    text ("Subject: Re: " + current_message.subject)
                else:
                    text ("To: " + contact.name)
                    text ("Subject: " + message_title)
                null  height 30

                for caption, action, chosen in items:

                    if action:
                        button:
                            action action
                            style "menu_choice_button" xalign 0.5

                            text caption text_align 0.5

                    else:
                        text caption style "menu_caption"
                        
    else:
        # this is the default choice menu
        window:
            style "menu_window"
            xalign 0.5
            yalign 0.5

            vbox:
                style "menu"
                spacing 2

                for caption, action, chosen in items:

                    if action:

                        button:
                            action action
                            style "menu_choice_button"

                            text caption style "menu_choice"

                    else:
                        text caption style "menu_caption"  
Attachments
Screen Shot 2014-08-31 at 4.24.10 PM.png
Choices menu w/o vbox

User avatar
Dragonstar89
Regular
Posts: 158
Joined: Mon Aug 12, 2013 11:28 pm
Projects: TBA
Organization: SenpaiJake Games/Paperviper
IRC Nick: dstar89
Deviantart: senpai-jake
Skype: dstar_891
Location: West Virginia, USA
Contact:

Re: Basic Message System

#55 Post by Dragonstar89 » Tue Dec 30, 2014 12:15 am

Wanted to change the textbutton to an image of a phone that changes screen color and shows the number of new mail when a message is received. I'm sure this isn't the best way to do this, but for those wanting to do similar here's how to (images included):

Code: Select all

screen my_valuee:
    text "[v] New" xpos 0.2 ypos 0.2
screen mailbox_overlay:
    if new_messages > 0:
        imagemap:
            xalign 1.0 yalign 0.0
            ground "phone_new.png"
            hotspot (0,1,116,56) action Show("mailbox"):
                use my_valuee(v=new_messages)
    else:
        imagemap:
            xalign 1.0 yalign 0.0
            ground "phone_idle.png"
            hotspot (0,1,116,57) action Show("mailbox")
# old code with the hbox for reference sake
     #hbox:
     #   xalign 1.0 yalign 0.0
     #   if new_messages > 0:
     #       textbutton "Mailbox ([new_messages] New)" action Show("mailbox")
     #   else:
     #       textbutton "Mailbox" action Show("mailbox")
Basically, the original code uses Ren'Py's "textbutton" function. I swapped that out with an imagemap and hotspots, then assigned my_valuee to be [v] (the given variable value, in this case new_messages) followed by the word "New."

Here's the phone image files I edited up.
phone_idle.png
The image for when there are no new messages
phone_idle.png (5.5 KiB) Viewed 3275 times
phone_new.png
The image for when there are more than 0 new messages.
phone_new.png (4.93 KiB) Viewed 3275 times
It ends up sorta like this:
prevvy.png
What it looks like in a basic scene set up (new message)
As for this:
Ryu-Kun wrote: All right man, this is a really cool feature! I can imagine how long it would've took to code all of this!
Now here's my question!
Is it possible to change the Menu with a image file?
Looking at "Message.rpy" I see how to change it, but you have to manually assign everything in align with the X and Y axis! What I want it to have the same screen, but on a phone, or something similar to that. I know you can do it with the menu in "Screens.rpy"!

(Basically, just put the messages on a phone, like this one:
I was wanting to do the same thing for my game. I'm going to be looking into it but it'd still be awesome if anyone else already has a solution.
Last edited by Dragonstar89 on Tue Dec 30, 2014 4:42 pm, edited 1 time in total.
Beginning pre-production work on a project in Renpy. After being away for 5 years, it's time to get back in the game 8)

User avatar
Karl_C
Veteran
Posts: 232
Joined: Sun Mar 31, 2013 6:18 am
Contact:

Re: Basic Message System

#56 Post by Karl_C » Tue Dec 30, 2014 11:25 am

Dragonstar89 wrote:Basically, the original code uses Ren'Py's "textbutton" function. I swapped that out with an imagemap and hotspots,
Just curious: Would it also be possible to use an imagebutton for that?

The imagebutton would have to change it's appearance, for instance from:
Image
to (New Mail):
Image
and after the mail is read possibly to:
Image

User avatar
Dragonstar89
Regular
Posts: 158
Joined: Mon Aug 12, 2013 11:28 pm
Projects: TBA
Organization: SenpaiJake Games/Paperviper
IRC Nick: dstar89
Deviantart: senpai-jake
Skype: dstar_891
Location: West Virginia, USA
Contact:

Re: Basic Message System

#57 Post by Dragonstar89 » Tue Dec 30, 2014 3:06 pm

Karl_C wrote:
Dragonstar89 wrote:Basically, the original code uses Ren'Py's "textbutton" function. I swapped that out with an imagemap and hotspots,
Just curious: Would it also be possible to use an imagebutton for that?
Uh, I didn't even know Ren'Py had an imagebutton option. I'm sure that would've saved a few minutes of time, heh. But I haven't tried that yet. You have 3 envelope images, if you wanted them all to show you would need to (most likely, I didn't create the message script from scratch so I wouldn't know) create a new instance that stores the value of having mail but it all is read mail to show the 3rd image. Right now you can easily change from one text/image to another given the script shared here already has the value new_messages to help make if's and else statements.

But yeah, I'm sure you can do the envelope. I don't think you'd need to use imagebutton either. Right now the way the script is my phone changes based on an if and else statement so I was able to assign a different image per status of the messages.
Beginning pre-production work on a project in Renpy. After being away for 5 years, it's time to get back in the game 8)

sharikah
Regular
Posts: 139
Joined: Sun Jun 08, 2014 1:36 am
Contact:

Re: Basic Message System

#58 Post by sharikah » Fri Jan 02, 2015 8:12 pm

Dragonstar89 wrote:Wanted to change the textbutton to an image of a phone that changes screen color and shows the number of new mail when a message is received. I'm sure this isn't the best way to do this, but for those wanting to do similar here's how to (images included):

Code: Select all

screen my_valuee:
    text "[v] New" xpos 0.2 ypos 0.2
screen mailbox_overlay:
    if new_messages > 0:
        imagemap:
            xalign 1.0 yalign 0.0
            ground "phone_new.png"
            hotspot (0,1,116,56) action Show("mailbox"):
                use my_valuee(v=new_messages)
    else:
        imagemap:
            xalign 1.0 yalign 0.0
            ground "phone_idle.png"
            hotspot (0,1,116,57) action Show("mailbox")
# old code with the hbox for reference sake
     #hbox:
     #   xalign 1.0 yalign 0.0
     #   if new_messages > 0:
     #       textbutton "Mailbox ([new_messages] New)" action Show("mailbox")
     #   else:
     #       textbutton "Mailbox" action Show("mailbox")
Basically, the original code uses Ren'Py's "textbutton" function. I swapped that out with an imagemap and hotspots, then assigned my_valuee to be [v] (the given variable value, in this case new_messages) followed by the word "New."

Here's the phone image files I edited up.
phone_idle.png
phone_new.png
It ends up sorta like this:
prevvy.png
As for this:
Ryu-Kun wrote: All right man, this is a really cool feature! I can imagine how long it would've took to code all of this!
Now here's my question!
Is it possible to change the Menu with a image file?
Looking at "Message.rpy" I see how to change it, but you have to manually assign everything in align with the X and Y axis! What I want it to have the same screen, but on a phone, or something similar to that. I know you can do it with the menu in "Screens.rpy"!

(Basically, just put the messages on a phone, like this one:
I was wanting to do the same thing for my game. I'm going to be looking into it but it'd still be awesome if anyone else already has a solution.
Does this go in the messages part or in the script?
Image

User avatar
Dragonstar89
Regular
Posts: 158
Joined: Mon Aug 12, 2013 11:28 pm
Projects: TBA
Organization: SenpaiJake Games/Paperviper
IRC Nick: dstar89
Deviantart: senpai-jake
Skype: dstar_891
Location: West Virginia, USA
Contact:

Re: Basic Message System

#59 Post by Dragonstar89 » Fri Jan 02, 2015 8:20 pm

sharikah wrote: Does this go in the messages part or in the script?
It goes in the messages.rpy file. Look where I commented out the old code in the snippets I shared - that's where you should paste it at.
Beginning pre-production work on a project in Renpy. After being away for 5 years, it's time to get back in the game 8)

User avatar
Karl_C
Veteran
Posts: 232
Joined: Sun Mar 31, 2013 6:18 am
Contact:

Re: Basic Message System

#60 Post by Karl_C » Sun Jan 11, 2015 9:12 am

balldancing wrote: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 *-*
Did you succeed to achieve your layout? I'm a bit lost as well...

Post Reply

Who is online

Users browsing this forum: No registered users