Page 1 of 1

Calling Image Attribute by Variable

Posted: Sun Jan 12, 2020 3:16 am
by gimyosan
I'm trying to implement a semi-randomized outfit system where a character is dressed consistently for a period of time. I'm currently using a layered image system for the clothing sprites and it works great, but I'm a bit stuck on how to approach the randomizer system. I was thinking of something kind of like this:

Code: Select all

$ bottom = renpy.random.choice(["pants"])
$ top = renpy.random.choice(["collar", "longsleeve", "sweater"])

show npc armscrossed happy [bottom] [top]_armscrossed  
But that doesn't work due to the way layer image attributes are called. Does anyone have tips on how to tackle this problem?

Re: Calling Image Attribute by Variable

Posted: Sun Jan 12, 2020 10:56 pm
by gas
Layeredimages can use variables to set a picture for that layer, so you can use a renpy.random to randomize what to show.
Finally, the if statement adds a layer that selects between displayables using a Python statement. This is evaluated constantly, and the first condition that evaluates to true is the one that's displayed.