Side images that stay on screen?

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
OrsonDeWitt
Regular
Posts: 45
Joined: Thu Dec 06, 2018 3:23 am
Contact:

Side images that stay on screen?

#1 Post by OrsonDeWitt »

Hello. I have looked through dozens of forum posts with similar discussions, but after trying all of them, nothing seems to work for my particular case.
I have recently begun working on the visual side of my game and, despite thinking that it would be easy enough, have hit a roadblock that I can't overcome.
I want to have side images of non-speaking characters show up behind&on the side of the speaking character, greyed out, and get stacked one after one another in the sequence that they last spoke (speaker, big, last speaker, greyed out and small, second to last speaker, greyed out and small, etc). I am going the side image route because I do not want to write "show" every time. Instead, I am looking to define all the characters in the room via list at the beginning of the scene.
Then, I was thinking I could add this code in my "say" screen:

Code: Select all

if _last_say_who == "[character1]" and who != _last_say_who:
add "[character1]" xpos 350 ypos 620
replacing the [character1] and so on with entries from the list of people that are present in the room.
However, for some reason, all that happens is that the image flashes and does not stay on the screen. Plus, I have found that, for some reason, the value of " _last_say_who", despite changing in the console, remains the same on the screen. I have 2 side images of the same speaking character side-by-side, while his interlocutor is alone, instead of having the second character by his side. It's an all-around weird situation and I'd appreciate any help. Thanks.
Last edited by OrsonDeWitt on Tue Jul 06, 2021 6:44 am, edited 1 time in total.
I cannot reply to messages anymore.
> Your IP has been blocked because it is blacklisted.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Side images that stay on screen?

#2 Post by Imperf3kt »

You probably want a character callback.
https://www.renpy.org/doc/html/characte ... -callbacks
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

OrsonDeWitt
Regular
Posts: 45
Joined: Thu Dec 06, 2018 3:23 am
Contact:

Re: Side images that stay on screen?

#3 Post by OrsonDeWitt »

Imperf3kt wrote: Mon Jul 05, 2021 5:39 pm You probably want a character callback.
https://www.renpy.org/doc/html/characte ... -callbacks
I probably do, but I've been reading for hours and unfortunately have not found a way to achieve this.
Last edited by OrsonDeWitt on Thu Jul 15, 2021 9:03 am, edited 1 time in total.
I cannot reply to messages anymore.
> Your IP has been blocked because it is blacklisted.

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Side images that stay on screen?

#4 Post by philat »

I don't think you can have more than one side image showing anyway since for side images the TAG itself is side, which means any side image would replace any other side image. Since you said you would define who's in the scene anyway, I don't see why you couldn't just do a round of show statements at the top with regular images.

Example for moving the current speaking character to the front: viewtopic.php?t=50142#p486880

There are several examples of darkening non-speaking characters on the forum with different approaches so I would suggest looking to find one that suits yourself.

OrsonDeWitt
Regular
Posts: 45
Joined: Thu Dec 06, 2018 3:23 am
Contact:

Re: Side images that stay on screen?

#5 Post by OrsonDeWitt »

Okay, I have figured it out. Indeed, I did not have to use side images for this, and I did not even have to use "show" for this. If anyone is going to be looking for a solution, here's mine: (and a bonus question at the end)
- script.rpy:

Code: Select all

default interlocutors = [] # we start with an empty list which is going to be populated by people as they appear in an interaction
init python:
    	speaking = None
	def gray(name, event, **kwargs):
        	global speaking
        	speaking = name
       		if event == "show":
        		if speaking in interlocutors: #if the speaking character is already in the stack, remove it
                		interlocutors.remove(speaking) 
       		elif event == "slow_done":
            		if speaking not in interlocutors:
                		interlocutors.insert(0,speaking) #put the last speaker back into the stack on the first position
            		speaking = None
        	elif event == "end":
        		if speaking not in interlocutors:
                		interlocutors.insert(0,speaking) #put the last speaker back into the stack on the first position
            		speaking = None
	speaker = renpy.curry(gray)
define Ineni = Character(_("Ineni"), image="Ineni", callback=speaker("Ineni")) #add callback=speaker to call the function
- screen say(who, what):

Code: Select all

if len(interlocutors) > 0:
    hbox:
        xpos 0.2 ypos 0.65
        xminimum 150
        yminimum 200
        ymaximum 200
        default xgrid = len(interlocutors)
        grid xgrid 1 spacing 40: #draw a grid that will contain all the images of the characters
            allow_underfull True
            for i_name in interlocutors:
                imagebutton:
                    action NullAction()
                    idle "char/gr_" + i_name + ".png" xalign 0.5 yalign 0.5 xsize 50 ysize 50 #put a greyed out image of a character into the stack above the textbox (pre-edited)
And I also have a general scene that I call after each interaction to clean up. Among other things, it contains this:

Code: Select all

label clean:
    $ interlocutors = []
So now the list is going to be populated with characters as they speak, this list will be shown as gray character images by order of recency above the textbox, and it will be cleared as soon as a scene ends.

EDIT: I've noticed an issue with this. When the choice menu is about to pop up, for half a second all the characters in the interlocutors list appear in the grid, including the last speaker. And then, when you make a choice, it takes half a second for them to re-arrange again. Would anyone know what is causing this?
I cannot reply to messages anymore.
> Your IP has been blocked because it is blacklisted.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]