Showing two same screens on the same time

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
User avatar
Mirrodin
Regular
Posts: 114
Joined: Sun Mar 19, 2017 2:56 pm
Contact:

Showing two same screens on the same time

#1 Post by Mirrodin »

Hi guys,

The title is strange, let me explain you :
I have a screen 'note' wich show "reputation change system" (it's a really small interface on the right).

Sometime, choice of the player change reputation for two pnj at the same time. I want to show them on the same time.

My error : Only the second one appear.

On the label :

Code: Select all

            
            m_fr pensif "No, I dont like you two."
            
            show screen note ("-2",150,"vlad")
            $ vlad_reput.add_reput(-2)            
            
            show screen note ("-3",220,"camilla")
            $ camilla_reput.add_reput(-3)
            
On screen :

Code: Select all

# Screen réputation up/down    
screen note (message, y, nom):

    zorder 50
    style_prefix "note"
    
    frame at note_appear:
        
        add "interface/reputation/notifications/notification_[nom].png" xpos 1080 ypos y
        text "[message!tq]" xpos 1195 ypos y+40 
        
    timer 2.5 action Hide('note')

transform note_appear:
    on show:
        alpha 0
        linear .25 alpha 1.0
    on hide:
        linear .5 alpha 0.0


style note_frame is empty
style note_text is gui_text

style notify_frame:
    xalign 0.5 ypos 0.82 xpos 0.97
    background None #Frame("gui/notify.png", gui.notify_frame_borders, tile=gui.frame_tile)

style note_text:
    properties gui.text_properties("note")
    color "#432B01"
    size 40   
Can you help me with that ?

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Showing two same screens on the same time

#2 Post by xavimat »

I'd use a list to store the notes. This code uses a function to add more info to the list and to show the screen. If the screen is not showing, it empties the list, if it is still showing, it adds new info.
If you click fast enough to add the Eileen information before Vlad and Camilla are gone, you'll see the three of them. If you wait until Vlad and Camilla are gone, Eileen will appear alone.

Code: Select all

default note_list = []

init python:
    def add_note(message, nom):
        global note_list
        if not renpy.get_screen("note"):
            note_list = []
        note_list.append({"message":message, "nom":nom})
        renpy.hide_screen("note")
        renpy.show_screen("note")

label start:
    "Bla bla"
    $ add_note("-2", "Vlad")
    $ add_note("-3", "Camilla")
    pause
    $ add_note("+2000", "Eileen")
    pause
    return

screen note():
    vbox at note_appear:
        for i in note_list:
            frame:
                has vbox
                label i["nom"]
                text i["message"]
    timer 2.5 action Hide('note')

transform note_appear:
    on show:
        alpha 0
        linear .25 alpha 1.0
    on hide:
        linear .5 alpha 0.0
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: Google [Bot]