Page 4 of 7

Re: Basic Message System

Posted: Fri Aug 01, 2014 12:59 am
by balldancing
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 ><

Re: Basic Message System

Posted: Fri Aug 01, 2014 2:55 am
by xela
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.

Re: Basic Message System

Posted: Fri Aug 01, 2014 4:25 am
by balldancing
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

Re: Basic Message System

Posted: Fri Aug 01, 2014 7:45 am
by xela
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

Re: Basic Message System

Posted: Fri Aug 01, 2014 8:13 am
by balldancing
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!)

Re: Basic Message System

Posted: Fri Aug 01, 2014 8:17 am
by xela
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.

Re: Basic Message System

Posted: Fri Aug 01, 2014 8:29 am
by balldancing
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)

Re: Basic Message System

Posted: Mon Aug 04, 2014 10:41 am
by Ryu-Kun
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)

Re: Basic Message System

Posted: Sun Aug 31, 2014 4:35 pm
by MindlessLogic
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"  

Re: Basic Message System

Posted: Tue Dec 30, 2014 12:15 am
by Dragonstar89
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.
The image for when there are no new messages
The image for when there are no new messages
phone_idle.png (5.5 KiB) Viewed 5364 times
The image for when there are more than 0 new messages.
The image for when there are more than 0 new messages.
phone_new.png (4.93 KiB) Viewed 5364 times
It ends up sorta like this:
What it looks like in a basic scene set up (new message)
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.

Re: Basic Message System

Posted: Tue Dec 30, 2014 11:25 am
by Karl_C
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

Re: Basic Message System

Posted: Tue Dec 30, 2014 3:06 pm
by Dragonstar89
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.

Re: Basic Message System

Posted: Fri Jan 02, 2015 8:12 pm
by sharikah
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?

Re: Basic Message System

Posted: Fri Jan 02, 2015 8:20 pm
by Dragonstar89
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.

Re: Basic Message System

Posted: Sun Jan 11, 2015 9:12 am
by Karl_C
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...