Create your AI Cum Slut -70% for Mother's Day
x

Ren'Py Need help with ConditionSwitch, Variables and image changes.

Obscured_One

New Member
Jan 13, 2025
2
2
Hello there.

I'm a novice trying to work out how to make a basic Renpy game with some classic corruption mechanics. Right now what I'm trying to do is developing a ConditionSwitch that will allow the game to switch the image of a character as their corruption level changes. But for some reason I can't get the formula to actually work properly, I've been trying out three broad variations based on what google has to offer and neither really works:

What I am trying to do with this code:
I have a basic "Jackie new" image is meant to be replaced with a "Jackie Corrupted" when the "j.corruption" variable increases over 3. This is not hapening in the way I need it to.


Variation One:

image Jackie alt = ConditionSwitch (
"j.corruption == 3 >","Jackie new.png",
"j.corruption == < 3","Jackie Corrupted.png",
"True", "Jackie new.png"
)

Doesn't work at all:

I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/script.rpy", line 35, in script
image Jackie alt = ConditionSwitch (
File "game/script.rpy", line 35, in <module>
image Jackie alt = ConditionSwitch (
SyntaxError: unexpected EOF while parsing (<none>, line 1)


Variation Two:

image Jackie alt = ConditionSwitch (
"j.corruption == 0","Jackie new.png",
"j.corruption == 4","Jackie Corrupted.png",
"True", "Jackie new.png"
)

This one technically does the job, but only when the corruption variable is 4. The moment it goes above or beneath it reverts to the "True" image. While it's possible to just write out a dozen lines to account for the ten or so points I want to use for each variable, I know from the ConditonSwitch tutorial that it's possible to have a more dynamic system with more variations, but I'm just giving myself a headcahe trying to get it to work.

And speaking of heaches;


Variation Three is a product of sheer frustration and not really a true attempt but it doesn't crash the game so here it goes:


image Jackie alt = ConditionSwitch (
"j.corruption < 3","Jackie Corrupted.png",
"True", "Jackie new.png"
)

This one for some reason shows the corrupted image as the first one and then switches to the "True" image, when it's supposed to be the opposite.

I think that the solution is probably something very, very simple that I'm overlooking. But trying to find it is costing quite a bit of time, so if anyone here has some insight for a beginner then it would be appreciated.
 
Last edited:

peterppp

Erect Member
Donor
Mar 5, 2020
1,048
1,873
image Jackie alt = ConditionSwitch (
"j.corruption == 3 >","Jackie new.png",
"j.corruption == < 3","Jackie Corrupted.png",
"True", "Jackie new.png"
)
your comparison operators are not correct, and true shouldnt be there.
Code:
image Jackie alt = ConditionSwitch (
        "j.corruption <= 3","Jackie new.png",
        "j.corruption > 3","Jackie Corrupted.png"
        )
 

peterppp

Erect Member
Donor
Mar 5, 2020
1,048
1,873
I can't believe it was that easy. Thanks, I should have come here in the first place.
come to think of it, your third variation is probably better to use as it will always fall back to the "new" pic if no other condition matches. you just need to switch the < to a >

so like this
Code:
image Jackie alt = ConditionSwitch (
"j.corruption > 3","Jackie Corrupted.png",
"True", "Jackie new.png"
)