[Solved] Different characters for config.side_image_tag

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
Potato0095
Regular
Posts: 84
Joined: Sun May 08, 2016 8:40 pm
Projects: LoveCraft
itch: potato95
Location: Brazil
Contact:

[Solved] Different characters for config.side_image_tag

#1 Post by Potato0095 »

My game is heavily dependent on different character's sideimages being considered as of the protagonist's.

This means I want char1 to have their sideimage always shown at one point, and char2's sideimage to always show at another point.

My question is, can I somehow have different tags for config.side_image_tag throughout the game? And if I don't, can I somehow get the desired effect by other means? I'd also like to be able to use

Code: Select all

e happy "dialogue"
to change the character's expressions, so I'd prefer a method that keeps this syntax available. I've tried showing images at a layer higher than the textbox, but I ended up losing the syntax I just mentioned.
Last edited by Potato0095 on Tue Aug 17, 2021 2:46 am, edited 1 time in total.
"There are two types of lies: Lies that hurt, and lies that don't."

User avatar
Potato0095
Regular
Posts: 84
Joined: Sun May 08, 2016 8:40 pm
Projects: LoveCraft
itch: potato95
Location: Brazil
Contact:

Re: Different characters for config.side_image_tag

#2 Post by Potato0095 »

So... update on my thing, turns out I was able to change config.side_image_tag from inside my script and it worked? I was worried about changing it because it is set during init python, but I didn't see any side effects for changing it after init. Ended up getting the result I expected so far, different side images as main characters at different points throughout the game.

Edit: changing the variable and then rollbacking the game doesn't rollback the variable. It's not a problem for me, but it could be for some people needing this feature.
"There are two types of lies: Lies that hurt, and lies that don't."

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2405
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Different characters for config.side_image_tag

#3 Post by Ocelot »

Saving and loading won't store tag properly too IIRC.

Did you try to use ConditionSwitch or DynamicImage for that? Instead of changing whichever image is shown midgame, you just change what that image is displaying.
< < insert Rick Cook quote here > >

User avatar
Potato0095
Regular
Posts: 84
Joined: Sun May 08, 2016 8:40 pm
Projects: LoveCraft
itch: potato95
Location: Brazil
Contact:

Re: Different characters for config.side_image_tag

#4 Post by Potato0095 »

Ocelot wrote: Sun Aug 15, 2021 3:24 am Saving and loading won't store tag properly too IIRC.

Did you try to use ConditionSwitch or DynamicImage for that? Instead of changing whichever image is shown midgame, you just change what that image is displaying.
About the save and load not storing... The tag resets to the default defined at init. I could just use a persistent to set it I guess.

About the ConditionSwitch, I have too many variants of characters and expressions for it to be viable. If I'm understanding correctly, each condition can have only 1 displayable; I have more than 10 characters, each with more than 15-20 expressions. That's a lot of py conditions for one interaction, enough to make the game lag on low-end systems.

I don't know about DynamicImage in this context. It gets a variable that is interpolated at each interaction, but I guess I'd have to use onlayer, so I'd lose the "char expression 'text' " syntax (unless I find a way to keep that syntax). Besides, SideImage() already returns a displayable to show, so doing "x = SideImage()" and then "DynamicImage(x)" would be redundant, wouldn't it? I can't see how DynamicImage would help me. Since I never used it, I guess it could be that it's possible, I just don't know how to do it.

Edit:
Yeah, a persistent can totally overcome the save/load problem at init level. Everytime I define config.side_image_tag to something, I also define persistent.side_image_tag to that same thing. During init phase, config.side_image_tag is defined, but since it is different from the persistent, it is set to the persistent value instead of keeping the default.

Code: Select all

init:
    config.side_image_tag = "char1"
    if config.side_image_tag != persistent.side_image_tag:
        config.side_image_tag = persistent.side_image_tag
"There are two types of lies: Lies that hurt, and lies that don't."

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2405
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Different characters for config.side_image_tag

#5 Post by Ocelot »

Now play the game just before image tag should change. Save the game into slot 1. Continue until tag changes. Save the game into slot 2. Close the game. Launch the game and load slot 1. Check if tag is correct. Then load slot 2. Check if tag is correct. Then load slot 1 again and check tag once more.
< < insert Rick Cook quote here > >

User avatar
Potato0095
Regular
Posts: 84
Joined: Sun May 08, 2016 8:40 pm
Projects: LoveCraft
itch: potato95
Location: Brazil
Contact:

Re: Different characters for config.side_image_tag

#6 Post by Potato0095 »

Since this workaround works with a persistent, and due to the nature of persistent variables, it should only apply the last variable, not any variable. That's not a problem when loading your last save, but it is a problem if you're loading older files.

Since the load is way after init, there's not really a way to load a variable stored in the save to a defined variable such as config at run time.

I'll tinker a little and see what I can do. Maybe changing how the SideImage() itself works? I could simply use show every time I want the character to change expression...
"There are two types of lies: Lies that hurt, and lies that don't."

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2405
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Different characters for config.side_image_tag

#7 Post by Ocelot »

You can drop persistent altogether, and just use special label after_load to reinit config variable.

Actually, SideImage itself takes an argument: a tag to use. You can provide it instead of using config variable. (technically it overwrites config variable on each invocation)

Code: Select all

# Somewhere
default current_protag = "char1"

# When you need to change protagonist:
$ current_protag = "char2"

# part of screen which displays ide image
add SideImage(current_protag)
< < insert Rick Cook quote here > >

User avatar
Potato0095
Regular
Posts: 84
Joined: Sun May 08, 2016 8:40 pm
Projects: LoveCraft
itch: potato95
Location: Brazil
Contact:

Re: Different characters for config.side_image_tag

#8 Post by Potato0095 »

I didn't know about after_load. I also didn't know that SideImage() takes an argument; tinkering with it would've been so much easier.

What I ended up doing was removing the persistent workaround and editing 00sideimage.rpy.

I deleted config.side_image_tag and put a global side_image_tag as a replacement. Since this new var is a global, it is saved and loaded just as any other variables would once edited inside the game's script.

I honestly don't know if _side_per_interact() or SideImage() - methods declared in 00sideimage.rpy - are called in any other Ren'Py functions, but my game has not raised errors, didn't show any misbehaviours and the variable is perfectly kept through saving and loading (even after quitting the game), so I think it worked.
"There are two types of lies: Lies that hurt, and lies that don't."

Post Reply

Who is online

Users browsing this forum: No registered users