Using im.MatrixColor inside a conditionswitch (while using variables inside file name)

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
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Using im.MatrixColor inside a conditionswitch (while using variables inside file name)

#1 Post by namastaii »

I can do this in Python but I didn't want to if I didn't have to as this isn't my project anyway but basically, there are images with conditionswitches and they work perfectly fine with variables in place to switch the files etc

Code: Select all

image example = ConditionSwitch(
    "condition 1 etc", "images/image_[variable].png",
    "condition 2", "images/image_[variable]_2.png")
But if I add an image manipulator to the image, it suddenly doesn't recognize the variable. I get an error saying "Can't find file "image_[variable].png" and I've tried %s and {} with .format() and it just tells me the variable is not defined.

Code: Select all

image example = ConditionSwitch(
    "condition 1 etc", "images/image_[variable].png",
    "condition 2", im.MatrixColor("images/image_[variable].png", im.matrix.brightness(-0.2)))
Is there any way to do this while keeping it all in one image definition still? If I have to resort to creating multiple images, then I'm just going the Python route.

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Using im.MatrixColor inside a conditionswitch (while using variables inside file name)

#2 Post by Kia »

try:

Code: Select all

"images/image_{}.png".format(variable)

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Using im.MatrixColor inside a conditionswitch (while using variables inside file name)

#3 Post by namastaii »

I did haha (I commented below the first example I tried that) and yeah doesn't seem possible, I had to go with another route

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Using im.MatrixColor inside a conditionswitch (while using variables inside file name)

#4 Post by Kia »

that's odd, I just tested it and it works fine for me, maybe the initial value is missing or it's a file name mismatch.

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Using im.MatrixColor inside a conditionswitch (while using variables inside file name)

#5 Post by namastaii »

when I do it that way I get an error saying the variable doesn't exist. if I take out the im.matrixcolor then it reads the variable fine. so I don't really know. we ended up just making a .png layer to trigger in the live composite instead but yeah not sure why this wouldn't work. I asked in discord multiple times and nobody could help me.

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Using im.MatrixColor inside a conditionswitch (while using variables inside file name)

#6 Post by Kia »

it always helps to pin point the problem if you create a new project and test just that part of the code in it. maybe the problem has roots in other parts of the code

Post Reply

Who is online

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