How To Define Images Using Variables

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
K1tten
Newbie
Posts: 3
Joined: Tue May 21, 2019 7:12 pm
Tumblr: Sn0wycat
Deviantart: L0llipopKitty
itch: K1tten
Contact:

How To Define Images Using Variables

#1 Post by K1tten »

So, I'm modding Doki Doki Literature Club by Team Salvato, and I'm trying to input a variable into the image definitions to make them wear different clothes. Here's the code that I've tried:

image sayori 1g = im.Composite((960, 960), (0, 0), "sayori/1l[s_clothes].png", (0, 0), "sayori/1r[s_clothes].png", (0, 0), "sayori/g.png")

s_clothes is the variable. So, if the s_clothes variable is "a", it should be showing 1la.png, but it isn't working. It says it cannot find the image.

The weird thing is, it worked in a game that I'm making (not as a mod, as an original game). This is the code in my game where it works (we'll just pretend the character's name is Meep):
image meep 1 = LiveComposite(
(800, 770),
(0, 0), "/characters/meep/meep_body[meep_body].png",
(0, 0), "/characters/meep/meep_head1.png",
(0, 0), "/characters/meep/meep_brows[meep_brows].png",
(0, 0), "/characters/meep/meep_mouth[meep_mouth].png",
(0, 0), "meep blink"
)

So the "meep_body" variable changes the body position of Meep. So 1 would be crossed arms, for example. And that works fine. But I don't know why it isn't working in the mod I'm making.

K1tten
Newbie
Posts: 3
Joined: Tue May 21, 2019 7:12 pm
Tumblr: Sn0wycat
Deviantart: L0llipopKitty
itch: K1tten
Contact:

Re: How To Define Images Using Variables

#2 Post by K1tten »

bump

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: How To Define Images Using Variables

#3 Post by Per K Grok »

K1tten wrote: Tue May 21, 2019 7:25 pm So, I'm modding Doki Doki Literature Club by Team Salvato, and I'm trying to input a variable into the image definitions to make them wear different clothes. Here's the code that I've tried:

image sayori 1g = im.Composite((960, 960), (0, 0), "sayori/1l[s_clothes].png", (0, 0), "sayori/1r[s_clothes].png", (0, 0), "sayori/g.png")

s_clothes is the variable. So, if the s_clothes variable is "a", it should be showing 1la.png, but it isn't working. It says it cannot find the image.

The weird thing is, it worked in a game that I'm making (not as a mod, as an original game). This is the code in my game where it works (we'll just pretend the character's name is Meep):
image meep 1 = LiveComposite(
(800, 770),
(0, 0), "/characters/meep/meep_body[meep_body].png",
(0, 0), "/characters/meep/meep_head1.png",
(0, 0), "/characters/meep/meep_brows[meep_brows].png",
(0, 0), "/characters/meep/meep_mouth[meep_mouth].png",
(0, 0), "meep blink"
)

So the "meep_body" variable changes the body position of Meep. So 1 would be crossed arms, for example. And that works fine. But I don't know why it isn't working in the mod I'm making.

You could try

"sayori/1l" + s_clothes + ".png"

K1tten
Newbie
Posts: 3
Joined: Tue May 21, 2019 7:12 pm
Tumblr: Sn0wycat
Deviantart: L0llipopKitty
itch: K1tten
Contact:

Re: How To Define Images Using Variables

#4 Post by K1tten »

Per K Grok wrote: Sat May 25, 2019 7:10 am
K1tten wrote: Tue May 21, 2019 7:25 pm So, I'm modding Doki Doki Literature Club by Team Salvato, and I'm trying to input a variable into the image definitions to make them wear different clothes. Here's the code that I've tried:

image sayori 1g = im.Composite((960, 960), (0, 0), "sayori/1l[s_clothes].png", (0, 0), "sayori/1r[s_clothes].png", (0, 0), "sayori/g.png")

s_clothes is the variable. So, if the s_clothes variable is "a", it should be showing 1la.png, but it isn't working. It says it cannot find the image.

The weird thing is, it worked in a game that I'm making (not as a mod, as an original game). This is the code in my game where it works (we'll just pretend the character's name is Meep):
image meep 1 = LiveComposite(
(800, 770),
(0, 0), "/characters/meep/meep_body[meep_body].png",
(0, 0), "/characters/meep/meep_head1.png",
(0, 0), "/characters/meep/meep_brows[meep_brows].png",
(0, 0), "/characters/meep/meep_mouth[meep_mouth].png",
(0, 0), "meep blink"
)

So the "meep_body" variable changes the body position of Meep. So 1 would be crossed arms, for example. And that works fine. But I don't know why it isn't working in the mod I'm making.

You could try

"sayori/1l" + s_clothes + ".png"
Thanks! I'll try that.

Post Reply

Who is online

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