Apparently the configuration variable
Code: Select all
define config.adjust_attributes = {}
Can anyone help explain it to me? Use layman terms where possible. Thank you.
Code: Select all
define config.adjust_attributes = {}
What do you mean by "automatically". You just said you don't want "if" statements, but then you talk about writing a function for it. You realize that that function still will need if statements if there are any conditions for the clothes. So what is it exactly that is bothering you?
That I don't want to keep on writing "if" statements every time the main character changes an item of clothing, as there will be a lot more clothing. So, everything I trying to figure out 'dynamism in attributes', as the ren'py documentation put its in Layered Images (attached link it's right at the bottom).m_from_space wrote: ↑Tue Apr 16, 2024 5:50 am What do you mean by "automatically". You just said you don't want "if" statements, but then you talk about writing a function for it. You realize that that function still will need if statements if there are any conditions for the clothes. So what is it exactly that is bothering you?
Code: Select all
define config.adjust_attributes = {}
Not sure you understand how layered images work, in general you don't have to use any if-statements.
You don't have to use if statements, unless you want to change the default attributes within a layered image, which is what I am trying to explain. I want the player to be able swap clothing, and have it stick. I know I can use layered images, as that link you shared shows, but to give you an example, scroll to the very bottom of that webpage, and you'll see the "config.adjust_attributes = {}" in use. It's used alongside a function, so you don't need a lengthy set of if statements - which is what I will need, because my main character will have a lot of clothing that players can adjust. I can figure out the loop if I try hard enough, but I wondering what that configuration variable does.m_from_space wrote: ↑Wed Apr 17, 2024 5:55 am Not sure you understand how layered images work, in general you don't have to use any if-statements.
But maybe you could give us an example on what you are referring to.
It's the first time you mention that you want the player to change the clothes. How am I supposed to know that?
Code: Select all
# define your layered image, named "eileen" in this case
layeredimage eileen:
attribute base default
group outfit auto
group ribbon prefix "ribbon":
attribute red
attribute blue
# a variable that defines the color of the ribbon
default eileen_ribbon_color = "red"
# create the adjusting function
init python:
def eileen_adjuster(names):
# pick all the attributes
# the first element at index 0 is not an attribute, but the tag "eileen", so we do not include it
atts = set(names[1:])
# if the image is shown with a ribbon tag at the moment
# let's remove it and replace it with a specific ribbon color saved inside the variable
if "ribbon" in atts:
atts.remove("ribbon")
atts.add("ribbon_" + eileen_ribbon_color)
# return the tag and the new attributes
return names[0], *atts
# connect the layered image called "eileen" with the function
define config.adjust_attributes["eileen"] = eileen_adjuster
Code: Select all
label start:
# This does not show any ribbon
show eileen
# This will show Eileen with the red ribbon, since 'ribbon' will be replaced by 'ribbon_red'
show eileen ribbon
# This will not change the ribbon on the fly with the current function
$ eileen_ribbon_color = "blue"
# Only after that it will change to the blue color
show eileen ribbon
Maybe I should point out, that you don't have to write all if conditions inside the layered image. You can also define images that are based on conditions in the first place and then incorporate them into the layered image.
Code: Select all
default pants_color = "black"
image mike_outfit_pants = ConditionSwitch(
"pants_color == 'red'", "red_pants",
"pants_color == 'black'", "black_pants",
# no image/pants when no condition is True
"True", Null()
)
layeredimage mike:
always:
"mike_body"
group outfit:
attribute shorts
attribute pants
attribute skirt
label start:
# nude mike
show mike
# show with black pants
show mike pants
# change to red pants on the fly
$ pants_color = "red"
Sorry, I should have been clearer. I thought I was at first. Either way, the ConditionSwitch, as well as the explanation of what the config variable does, was helpful. Thank you!m_from_space wrote: ↑Thu Apr 18, 2024 6:39 am It's the first time you mention that you want the player to change the clothes. How am I supposed to know that?
Users browsing this forum: Google [Bot]