help with variable composite expression
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.
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.
- Qlara
- Regular
- Posts: 80
- Joined: Fri Nov 28, 2014 10:22 am
- Completed: Carmilla
- Skype: kantonija
- itch: visualgothic
- Location: Berlin
- Contact:
help with variable composite expression
Hello,
I'm struggling with the definition of my character composites.
There's no way this hasn't been answered before, but I am unable to locate any threads regarding the matter.
I have seen the immensely helpful posting by OokamiKasumi, but it doesn't quite fit the bill.
Here's the problem:
For my character I have around 10 to 20 images each for brows, eyes and mouth.
Combining them to form a variety of complete expressions and naming those is too tedious beyond the obvious ones.
Instead, I'd like to change single parts on the fly, during coding that is.
How can I define a composite that would work something like this (pseudocode):
Laura = composite of [base, brow, eyes, mouth]
where
base = lau.png
brow = b1.png, b2.png, ..., bn.png
eyes = e1.png, e2.png, ..., en.png
mouth = m1.png, m2.png, ..., mn.png
and then call it with
show image Laura [b2, e4, m1]
Thanks a lot,
Qlara
I'm struggling with the definition of my character composites.
There's no way this hasn't been answered before, but I am unable to locate any threads regarding the matter.
I have seen the immensely helpful posting by OokamiKasumi, but it doesn't quite fit the bill.
Here's the problem:
For my character I have around 10 to 20 images each for brows, eyes and mouth.
Combining them to form a variety of complete expressions and naming those is too tedious beyond the obvious ones.
Instead, I'd like to change single parts on the fly, during coding that is.
How can I define a composite that would work something like this (pseudocode):
Laura = composite of [base, brow, eyes, mouth]
where
base = lau.png
brow = b1.png, b2.png, ..., bn.png
eyes = e1.png, e2.png, ..., en.png
mouth = m1.png, m2.png, ..., mn.png
and then call it with
show image Laura [b2, e4, m1]
Thanks a lot,
Qlara
- Divona
- Miko-Class Veteran
- Posts: 678
- Joined: Sun Jun 05, 2016 8:29 pm
- Completed: The Falconers: Moonlight
- Organization: Bionic Penguin
- itch: bionicpenguin
- Contact:
Re: help with variable composite expression
Here are the treads relating to LiveComposite and ConditionSwitch.
- Use of LiveComposite and ConditionSwitch together
- Customizing/Creating a Character, and Conditional Images
- Use of LiveComposite and ConditionSwitch together
- Customizing/Creating a Character, and Conditional Images
- Qlara
- Regular
- Posts: 80
- Joined: Fri Nov 28, 2014 10:22 am
- Completed: Carmilla
- Skype: kantonija
- itch: visualgothic
- Location: Berlin
- Contact:
Re: help with variable composite expression
Hello,
thank you for trying to help, but unfortunately those solutions are not what I'm looking for.
What I'd like to do is more akin to inputting an array or matrix and then calling a position. Under no circumstance do I wish to think about (expression-) names for the approximately 12 x 22 x 11 possible combinations upfront.
Does anybody know how to read an array or list of image objects which can then then be called by their index?
Qlara
thank you for trying to help, but unfortunately those solutions are not what I'm looking for.
What I'd like to do is more akin to inputting an array or matrix and then calling a position. Under no circumstance do I wish to think about (expression-) names for the approximately 12 x 22 x 11 possible combinations upfront.
Does anybody know how to read an array or list of image objects which can then then be called by their index?
Qlara
- Divona
- Miko-Class Veteran
- Posts: 678
- Joined: Sun Jun 05, 2016 8:29 pm
- Completed: The Falconers: Moonlight
- Organization: Bionic Penguin
- itch: bionicpenguin
- Contact:
Re: help with variable composite expression
You don't need to name every expression using LiveComposite. Here is an example to get the closest to what you're after:
Code: Select all
default brow = "b1"
default eyes = "e1"
default mouth = "m1"
image laura = LiveComposite(
(300, 300),
(0, 0), "lau.png",
(0, 0), "[brow].png",
(0, 0), "[eyes].png",
(0, 0), "[mouth].png"
)
label start:
show laura
"This is Laura with brow = b1, eyes = e1, mouth = m1."
$ brow, eyes, mouth = "b2", "e4", "m1"
"This is Laura with brow = b2, eyes = e4, mouth = m1."
- Qlara
- Regular
- Posts: 80
- Joined: Fri Nov 28, 2014 10:22 am
- Completed: Carmilla
- Skype: kantonija
- itch: visualgothic
- Location: Berlin
- Contact:
Re: help with variable composite expression
Hello,
that seems to be the right solution, but I don't understand it quite yet.
I've done the following:
When I try calling
naturally, the system returns the question "What is brows?" [brows undefined]
I'm lacking a vital piece here.
[brows] is variable, isn't it? How and where do I define it?
that seems to be the right solution, but I don't understand it quite yet.
I've done the following:
Code: Select all
# define my image parts:
image lb1 = "lau/brows/b1.png"
image lb2 = "lau/brows/b2.png"
image le1 = "lau/eyes/e1.png"
image le2 = "lau/eyes/e2.png"
# then your code - more or less:
default brows = "lb1"
default eyes = "le1"
image lau= LiveComposite(
(513, 720),
(0, 0), "lau/base.png",
(0, 0), "[brows].png",
(0, 0), "[eyes].png"
)
Code: Select all
$ brows, eyes = "lb2", "le2"I'm lacking a vital piece here.
[brows] is variable, isn't it? How and where do I define it?
- Divona
- Miko-Class Veteran
- Posts: 678
- Joined: Sun Jun 05, 2016 8:29 pm
- Completed: The Falconers: Moonlight
- Organization: Bionic Penguin
- itch: bionicpenguin
- Contact:
Re: help with variable composite expression
The code you provided should give you:
Instead of:
You haven't provide the actual traceback error, so I'm guessing here.
According to your code, you have assign incorrect string value to "brows" and "eyes" variables.
You don't have file name "lb1.png" and "le1.png", which result to the system looking for actual file name "[brows].png" and can't find it, so it give you "IOError".
The correct values, according to your code, should be:
No need to define images before hand.
Code: Select all
IOError: Couldn't find file '[brows].png'
Code: Select all
NameError: name 'brows' is not defined
According to your code, you have assign incorrect string value to "brows" and "eyes" variables.
Code: Select all
default brows = "lb1"
default eyes = "le1"
"[brows].png" # This equal "lb1.png"
"[eyes].png" # This equal "le1.png"
The correct values, according to your code, should be:
Code: Select all
default brows = "b1"
default eyes = "e1"
image lau = LiveComposite(
(513, 720),
(0, 0), "lau/base.png",
(0, 0), "lau/brows/[brows].png",
(0, 0), "lau/eyes/[eyes].png"
)
- Qlara
- Regular
- Posts: 80
- Joined: Fri Nov 28, 2014 10:22 am
- Completed: Carmilla
- Skype: kantonija
- itch: visualgothic
- Location: Berlin
- Contact:
Re: help with variable composite expression
Oh dear, oh dear, now I don't get it all anymore. I'm really sorry.
I do in fact have images "lb1.png" and "le1.png", lb2.png ..... and they are in the right places as well.
How can I callif I have never defined those images?
Edit:
maybe I should clarify that my images have completely different names and due to my folder structure images/characters/char_name/brows/ab.png each character's i.e. "angry brow" can be named "ab.png", because they are in separate folders. However, when I define the image I must change ab to lab for Laura angry brow so that image names don't repeat.
Was it necessary to have them named from 1 to n in order for the code to work?
I do in fact have images "lb1.png" and "le1.png", lb2.png ..... and they are in the right places as well.
How can I call
Code: Select all
$ brows, eyes = "lb2", "le2"Edit:
maybe I should clarify that my images have completely different names and due to my folder structure images/characters/char_name/brows/ab.png each character's i.e. "angry brow" can be named "ab.png", because they are in separate folders. However, when I define the image I must change ab to lab for Laura angry brow so that image names don't repeat.
Was it necessary to have them named from 1 to n in order for the code to work?
Last edited by Qlara on Wed Jan 04, 2017 12:18 am, edited 2 times in total.
- Divona
- Miko-Class Veteran
- Posts: 678
- Joined: Sun Jun 05, 2016 8:29 pm
- Completed: The Falconers: Moonlight
- Organization: Bionic Penguin
- itch: bionicpenguin
- Contact:
Re: help with variable composite expression
You don't have to define those image parts because you is defining "lau" as LiveComposite displayable already.
When you call:
Would equal:
Does "lau/brows/lb2.png" and "lau/eyes/le2.png" are the correct file paths?
Code: Select all
image lau = LiveComposite()
Code: Select all
$ brows, eyes = "lb2", "le2"
Code: Select all
image lau = LiveComposite(
(513, 720),
(0, 0), "lau/base.png",
(0, 0), "lau/brows/lb2.png",
(0, 0), "lau/eyes/le2.png"
)
- Qlara
- Regular
- Posts: 80
- Joined: Fri Nov 28, 2014 10:22 am
- Completed: Carmilla
- Skype: kantonija
- itch: visualgothic
- Location: Berlin
- Contact:
Re: help with variable composite expression
I was afraid you'd say that.
Do you mean to suggest that I define all possible combinations as composites, because my question was precisely how to avoid that.
(I edited my previous reply to include my folder structure.)
Do you mean to suggest that I define all possible combinations as composites, because my question was precisely how to avoid that.
(I edited my previous reply to include my folder structure.)
- Qlara
- Regular
- Posts: 80
- Joined: Fri Nov 28, 2014 10:22 am
- Completed: Carmilla
- Skype: kantonija
- itch: visualgothic
- Location: Berlin
- Contact:
Re: help with variable composite expression
Here is the actual code: And here is the actual error:
While loading <'Image' '[brows].png'>:
File "game/chap_01.rpy", line 10, in script
narL "In Styria, we, though by no means magnificent people, inhabit a castle, or schloss."
IOError: Couldn't find file '[brows].png'.
Code: Select all
image lba = "art/chars/lau/brows/a.png"
image lbh = "art/chars/lau/brows/h.png"
image lbi = "art/chars/lau/brows/i.png"
image lec = "art/chars/lau/eyes/c.png"
image lel = "art/chars/lau/eyes/l.png"
image les = "art/chars/lau/eyes/s.png"
image lma = "art/chars/lau/mouth/a.png"
image lmaw = "art/chars/lau/mouth/aw.png"
image lmsf = "art/chars/lau/mouth/sf.png"
default brows = "lba"
default eyes = "lec"
default mouth = "lma"
image lau_nar = LiveComposite(
(516, 730),
(0,0), "art/chars/lau/base.png",
(0,0), "[brows].png",
(0, 0), "[eyes].png",
(0, 0), "[mouth].png"
)Code: Select all
show lau_nar at center # default expression
narL "In Styria, we, though by no means magnificent people, inhabit a castle, or schloss."
$ brows, eyes, mouth = "lbh", "lel", "lmaw"
narL "A small income, in that part of the world, goes a great way. Eight or nine hundred a year does wonders."While loading <'Image' '[brows].png'>:
File "game/chap_01.rpy", line 10, in script
narL "In Styria, we, though by no means magnificent people, inhabit a castle, or schloss."
IOError: Couldn't find file '[brows].png'.
- Divona
- Miko-Class Veteran
- Posts: 678
- Joined: Sun Jun 05, 2016 8:29 pm
- Completed: The Falconers: Moonlight
- Organization: Bionic Penguin
- itch: bionicpenguin
- Contact:
Re: help with variable composite expression
It is "IOError" as I suspected. That's mean it can't find the file.
According to the path you have provided above, this is how the code should be:
According to the path you have provided above, this is how the code should be:
Code: Select all
default brows = "a"
default eyes = "c"
default mouth = "a"
image lau_nar = LiveComposite(
(516, 730),
(0, 0), "art/chars/lau/base.png",
(0, 0), "art/chars/lau/brows/[brows].png",
(0, 0), "art/chars/lau/eyes/[eyes].png",
(0, 0), "art/chars/lau/mouth/[mouth].png"
)
label start:
show lau_nar at center # default expression
narL "In Styria, we, though by no means magnificent people, inhabit a castle, or schloss."
$ brows, eyes, mouth = "h", "l", "aw"
narL "A small income, in that part of the world, goes a great way. Eight or nine hundred a year does wonders."
Last edited by Divona on Wed Jan 04, 2017 12:59 am, edited 1 time in total.
- Qlara
- Regular
- Posts: 80
- Joined: Fri Nov 28, 2014 10:22 am
- Completed: Carmilla
- Skype: kantonija
- itch: visualgothic
- Location: Berlin
- Contact:
Re: help with variable composite expression
Okay, got it, now it works perfectly. Puh, I thought we had a misunderstanding and you actually did expect me to spell it all out.
In the future, I will stick to actual code when problem solving and not simplifying it wrongly, and thus, overcomplicating matters exponentially. I'm sorry and thanks a lot!
In the future, I will stick to actual code when problem solving and not simplifying it wrongly, and thus, overcomplicating matters exponentially. I'm sorry and thanks a lot!
Who is online
Users browsing this forum: _ticlock_
