Modifying Messages/Phone Text Systems

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Kunabee
Newbie
Posts: 6
Joined: Thu Jul 07, 2011 2:33 am
Contact:

Modifying Messages/Phone Text Systems

#1 Post by Kunabee »

I hate socializing, but Google and my innovation have failed me, so I guess I'm asking this. I'm also a big old slacker who tends to disappear at random so, I mean, I've conversationed with people before and then just DISAPPEARED (as I do). Consistency? A farce.

Anywho, I've been modifying saguaro's basic messaging script to try and create a little phone thing. I've also snagged some things from Nadia Nova's mobile phone script, such as modifying the phone graphic provided (which is from Cute Demon Crashers? I played that game, I do not remember a phone, but also I'm dumb).

What I'm trying to do, is, basically, have a list of contacts. You select one of the names, and your entire conversation pops up and you can scroll through it. I've gotten it where a single message will pop up when clicking the contacts, but that's not how texts work, is it?

There should be a back and forth, with history you can scroll back through. So, basically, you have one box that's in a bubble from the contact, and then another box in a different bubble from the PC. A left/right thing like it would be in a real phone.

I know Nadia's works by having this defined by two different screens for incoming vs outgoing texts. I don't want to do that, because I want there to be a history - so when you click it, you see all previous messages (or you can, if you scroll). But instead of having it clumped together, it's appropriately spaced out. The one thing I 'get' how to do is adding a label of the name - create a variable of 'contact name' (or something appropriately named) and have that be the vbox label, although I'm not sure how to make it work similar to the way messages work...

Anyone who could help me with this would be greatly appreciated.

I actually solved one problem I had while typing this up, but I just... have no idea what to do with this or how to get it working.

You ready for super messy code? I have things roughly labeled, but there are some unused things in there and it's just... not organized, yet. (Like I want to further divide saguaro's code up with comments... LOOK, I've done the whole game of 'NO COMMENTS EVER' and it sucks. Everything is commented now).

Code: Select all

#defining images
image phone = "images/phone stuff/phone.png"

# Phone transforms - Nadia Nova
transform phone_pickup:
    yalign 1.0 xalign 0.5
    yoffset 900
    easein 0.3 yoffset 50

transform phone_hide:
    yalign 1.0 xalign 0.5
    yoffset 100
    easein 0.3 yoffset 1300

# Phone start and Phone End - Nadia Nova
label phone_start:
    window hide
    show phone at phone_pickup
    show screen phone_contacts
    $ renpy.pause(0.2)
    return

label phone_end:
    hide screen phone_contacts
    hide screen phone_message
    show phone at phone_hide
    $ renpy.pause(0.2)
    return

##Basic Message System 1.2 provided under CC0 1.0 Universal by saguaro, includes contributions by xavimat
# http://creativecommons.org/publicdomain/zero/1.0/deed.en
# See Lemma Soft Forum for most recent version: http://lemmasoft.renai.us/forums/viewtopic.php?f=51&t=19295

init python:
    import renpy.store as store

    reply_screen = False
    current_message = None
    sender = None

    class Mail(store.object):
        def __init__(self, sender, body, reply_label=False, view=True, read=False):
            self.sender = sender
            self.body = body
            self.reply_label = reply_label
            self.view = view
            self.read = read
            self.deliver()

        def delete(self):
            self.view = False
            renpy.restart_interaction()

        def mark_read(self):
            self.read = True
            renpy.restart_interaction()

        def reply(self):
            global reply_screen
            reply_screen = True
            renpy.call_in_new_context(self.reply_label, current_message=self)
            reply_screen = False

    class Contact(store.object):
        def __init__(self, name):
            self.name = name
            self.add_contact()

        def add_contact(self):
            contacts.append(self)

        def delete(self):
            contacts.remove(self)

    def add_message(sender, body, reply_label=False):
        message = Mail(sender, body, reply_label)

    def check(subject):
        for item in mail:
            if item.subject == subject:
                if item.read:
                    return True
                else:
                    return False

    def message_count():
        visible_messages = [x for x in mail if x.view]
        return len(visible_messages)

    def new_message_count():
        unread_messages = [ x for x in mail if not x.read]
        return len(unread_messages)

screen mailbox_overlay:
    hbox:
        xalign 1.0 yalign 0.0
        if new_message_count() > 0:
            textbutton "Check Phone (New)" action Call("phone_start")
        else:
            textbutton "Check Phone" action Call("phone_start")

screen phone_contacts:
    tag menu
    modal True
    frame:
        style_group "mailbox"
        vbox:
            label "Messages"
            side "c r":
                area (0,18,370,440)
                viewport id "contacts_list":
                    draggable True mousewheel True
                    vbox:
                        for i in mail:
                            if i.view:
                                if not i.read:
                                    textbutton ( i.sender +  " *NEW MESSAGES") action [SetVariable("current_message",i), SetVariable("sender",i), Hide("phone_contacts"), i.mark_read, Show("phone_message")] xfill True
                                else:
                                    textbutton (i.sender) action [SetVariable("current_message",i), SetVariable("sender",i), Hide("phone_contacts"), Show("phone_message")] xfill True
                vbar value YScrollValue("contacts_list")
            hbox:
                null height 20

screen phone_message:
    tag menu
    modal True
    frame:
        style_group "mailbox"
        vbox:
            label "[sender]"
            side "c r":
                area (0,123,370,440)
                viewport id "view_message":
                    draggable True mousewheel True
                    vbox:
                        if current_message:
                            text current_message.body
                vbar value YScrollValue("view_message")
            use mailbox_commands
        hbox:
            null height 20

screen mailbox_commands:
    hbox:
        area (0,0,100,200)
        if current_message and current_message.reply_label:
            textbutton "Reply" action current_message.reply
        else:
            textbutton "Reply" action None
        textbutton "Exit" action [Hide("phone_contacts"), Hide("phone_message"), Call("phone_end")]

screen contacts:
    modal True
    frame:
        style_group "mailbox"
        xsize 200
        vbox:
            label "Contacts"
            for name in contacts:
                if name.draft_label:
                    textbutton name.name action [name.draft, Hide("contacts")]
                else:
                    textbutton name.name action None
            textbutton "Close" action Hide("contacts")

init -2 python:
    style.mailbox = Style(style.default)
    style.mailbox_vbox.xalign = 0.5
    style.mailbox_vbox.xfill = False
    style.mailbox_hbox.xalign = 0.5
    style.mailbox_label_text.size = 30
    style.mailbox_label_text.xalign = 0.6
    style.mailbox_label.xfill = False
    style.mailbox_frame.xalign = 0.5
    style.mailbox_frame.yalign = 0.5
    style.mailbox_frame.background = "images/phone stuff/transparent.png"
Don't mind me, I'm going to be modifying the appearance so it actually looks right and functions other than the back/forth I want...
Last edited by Kunabee on Fri Nov 16, 2018 3:56 am, edited 2 times in total.


Kunabee
Newbie
Posts: 6
Joined: Thu Jul 07, 2011 2:33 am
Contact:

Re: Modifying Messages/Phone Text Systems

#3 Post by Kunabee »

That is... exactly what I wanted and I'm upset I didn't find it.

Thank you so much. I appreciate you immensely!

EDIT: So it wasn't exactly what I wanted, but I'm starting to jury-rig something.

I have... two, new problems. Well, one isn't entirely new, but I'm tired and I forgot to mention it in the beginning.

1 - The way the code is set up, the screen pops up and THEN the phone image. It's animated (ty nadia nova) and it essentially is 'MESSAGES' and everything, and the phone slides up behind it. Not game-breaking, but, irritating. Is there a way to make a wait command in the 'action' part of a textbutton?

2 - I basically need to store conversations in contacts. Easy enough to make each contact a variable, I already kind of need that for the contacts screen! I'm currently trying to get something working where messages are stored as arrays under each contact variable. So you have the contacts array for the list to display, then you click a contact and, bam, the array under the contact's name pulls up all their messages. I might work this out when I wake up tomorrow with fresh eyes and sleep, but if anyone could give me a hand I'd be thrilled.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], decocloud