Help with phone messaging system

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
andriodmactemporary
Regular
Posts: 27
Joined: Mon Jan 25, 2021 5:35 pm
Contact:

Help with phone messaging system

#1 Post by andriodmactemporary »

I have created a messaging system in which each message is displayed with an HBOX, and messages are stored in a dictionary field of array type data structure.
Whenever I want to add a new message, I will append that message to the dictionary field array.
Then due to for loop messages hbox's will be re-drawn.

But problem is that all hbox's are being drawn at a time, I want to a little pause between each hbox / message.

Below is my messages data structure :

Code: Select all

$ persons = {
    0 : {'Name' : 'Person1', 'relationshipPoints' : -80, 'avatarPath' : 'contacts/person1.png', 'index' : 0,
        'chatHistory' :
        [
           [b] {'type' : 'reply-message', 'message' : 'Got your message'},
            {'type' : 'forward-message', 'message' : 'Hello'},
            {'type' : 'reply-message', 'message' : 'How are you'},
            {'type' : 'forward-message', 'message' : 'Good how about you'},
            {'type' : 'reply-message', 'message' : 'Sending image ...'},
            {'type' : 'reply-image', 'imagePath' : 'chat/1.1.jpg'},
            {'type' : 'reply-message', 'message' : 'The quick brown fox jumps over the lazy dog'},
            {'type' : 'forward-message', 'message' : 'Good night'},
            {'type' : 'reply-image', 'imagePath' : 'chat/2.2.jpg'},
            {'type' : 'forward-message', 'message' : 'Bye'},
            {'type' : 'reply-image', 'imagePath' : 'chat/3.1.jpg'}[/b]

        ],
        
        
        'greetToday' : True, 'friendlyMessagesToday' : 0, 'meanMessagesToday' : 0, 'todayChatImage' : True, 'enabled' : True
    },
    1 : {'Name' : 'Person2', 'relationshipPoints' : -60, 'avatarPath' : 'contacts/person2.png', 'index' : 1,
    'chatHistory' :
            [
               [b] {'type' : 'forward-message', 'message' : 'Hello'},
                {'type' : 'reply-message', 'message' : 'How are you'},
                {'type' : 'forward-message', 'message' : 'Good how about you'}[/b]
            ],
            'greetToday' : True, 'friendlyMessagesToday' : 0, 'meanMessagesToday' : 0, 'todayChatImage' : True, 'enabled' : True
    }
And, below is code for appending new messaged :

Code: Select all

 persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'forward-message', 'message' : text})

                persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'reply-message', 'message' : 'Fine'})

                persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'forward-message', 'message' : "Let's meet somewhere"})

                persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'reply-message', 'message' : 'Shop or Office'})
                persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'reply-image', 'imagePath' : 'Shop.png'})
                persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'reply-image', 'imagePath' : 'Office.jpg'})
Here after each append I want to pause and re-draw the screen

Below, is the code for hbox's :

Code: Select all

 for i in selectedPerson['chatHistory']:
                frame:
                    xsize 1150

                    background "transparent.png"
                    hbox:
                        spacing 10
                        if i['type'] == "forward-message":
                            xalign 1.0
                            frame :
                               background "#ffcfd2"
                               $tempMessage = i['message']
                               text "[tempMessage]" color getChatTextColor(selectedPerson['relationshipPoints'])
                            imagebutton:
                                idle Frame("icons/user.png", 0, 0)
                                minimum(64, 64)
                                maximum(64, 64)
                        elif i['type'] == "reply-message":
                            xalign 0.0
                            imagebutton:
                                idle Frame(selectedPerson['avatarPath'], 0, 0)
                                minimum(64, 64)
                                maximum(64, 64)
                            frame :
                               background "#ffcfd2"
                               $tempMessage = i['message']
                               text "[tempMessage]" color getChatTextColor(selectedPerson['relationshipPoints'])
                        elif i['type'] == "reply-image":
                            imagebutton:
                                idle Frame(selectedPerson['avatarPath'], 0, 0)
                                minimum(64, 64)
                                maximum(64, 64)

                            imagebutton:
                                idle Frame(i['imagePath'])
                                minimum(256, 144)
                                maximum(256, 144)
                                action Call("enlargeChatImage", i['imagePath']), Return(None)
I have already tried renpy.pause(), Python time.sleep(); but with those, if I place them in multiple places program is pausing only once by taking all the seconds at once.

Below I have also attached video for reference :
https://drive.google.com/file/d/1ObwuWK ... sp=sharing

Post Reply

Who is online

Users browsing this forum: Bing [Bot]