Ren'Py Need help for a simple clothing system / rememberin player choice.

Likextra

New Member
Mar 3, 2022
3
0
Hi guys !

Sorry for asking. Maybe there is already the answer somewhere but I don't find it on the web.
I'm trying to create a game on Renpy (this is my first try) and I'm a little trapped on this problem.

For my first chapter, the game leads all the decisions that the player can take. So it's really easy to code. In chapter two I want to let more possibilities so I would like the player can choose between different clothing for the main characters but also the other characters in the game.
I have, in my case, 4 png with one clothing each.
Outfit 1 = png 1
Outfit 2 =png 2
...
It's the same for all the characters in the game.

If the player chooses to wear Outfit 1 (png 1). I want to know how the game can remember this choice and each time the character shows on screen he is wearing outfit 1. Until of course, the player decides to change it. Actually, in my script, I'm manually making appear the png I want, but it can't work with player choice.

It's of course, I guess, the same process for the other characters when the player chooses the outfit he will wear it each time he appears on screen.

Sorry is it's not very precise but I hope it will be ok to read !

Thanks a lot and have a good day :)
 

Winterfire

Forum Fanatic
Respected User
Game Developer
Sep 27, 2018
5,497
8,035
You need to create an id for each outfit, in your Game Document Design or other notes you can easily access, then store that ID in a variable.

Python:
default pickedOutfit = "redRobes001"
You can then use this string to show scenes like so:

Python:
scene ".../playerJumping_" + pickedOutfit + ".webp"
if you have few outfits, or an easier id, you could store them into an integer instead like so:

Python:
default pickedOutfit = 1
then use the integer within a string for your scenes:

Python:
scene ".../playerJumping_" + str(pickedOutfit) + ".webp"

-Edit-
Also, depending on your game, you could use:
 
Last edited:

Likextra

New Member
Mar 3, 2022
3
0
Hi, Thanks for reply !

I can understand the whole concept ! is it possible to have a more easier explanation ?
Just to understand each line and command ? It will be moire useful to learn
What is " .webp" and "str" ? For exemple

Thanks a lot and sorry for the my nooby development ;)
 

Winterfire

Forum Fanatic
Respected User
Game Developer
Sep 27, 2018
5,497
8,035
Hi, Thanks for reply !

I can understand the whole concept ! is it possible to have a more easier explanation ?
Just to understand each line and command ? It will be moire useful to learn
What is " .webp" and "str" ? For exemple

Thanks a lot and sorry for the my nooby development ;)
webp is an image file format, you'll want to use that as the size is smaller than png.

 

peterppp

Active Member
Mar 5, 2020
762
1,347
You need to create an id for each outfit, in your Game Document Design or other notes you can easily access, then store that ID in a variable.

Python:
default pickedOutfit = "redRobes001"
You can then use this string to show scenes like so:

Python:
scene ".../playerJumping_" + pickedOutfit + ".webp"
if you have few outfits, or an easier id, you could store them into an integer instead like so:

Python:
default pickedOutfit = 1
then use the integer within a string for your scenes:

Python:
scene ".../playerJumping_" + str(pickedOutfit) + ".webp"

-Edit-
Also, depending on your game, you could use:
less typing to do it like this
Python:
default outfit1 = "../playerJumping_redRobes.webp"
default outfit2 = "../playerJumping_blueRobes.webp"
default outfit3 = "../playerJumping_greenRobes.webp"

default pickedOutfit = outfit1
and then

Python:
scene pickedOutfit
 

Winterfire

Forum Fanatic
Respected User
Game Developer
Sep 27, 2018
5,497
8,035
less typing to do it like this
Python:
default outfit1 = "../playerJumping_redRobes.webp"
default outfit2 = "../playerJumping_blueRobes.webp"
default outfit3 = "../playerJumping_greenRobes.webp"

default pickedOutfit = outfit1
and then

Python:
scene pickedOutfit
No, you misunderstood my point. The idea is that he's making a western-style game with a CG every sentence (pretty much), so rather than a mess of "if" conditions, he writes the scene as normal, but taking an id (connected to a variable).

Of course if that's not the case, he can simply go for composite instead. I have no idea what type of game he's making, so I just assumed.


-edit-
"playerJumping" was just an example of one of the many scenes he could have, if we assume he's making a western-style VN:

Python:
label example:
    scene "playerJumping_" + pickedOutfit + ".webp"
    Speaker "Dialogue..."
    scene "playerRolling_" + pickedOutfit + ".webp"
    Speaker "More dialogue..."
    scene "playerDoesStuff_" + pickedOutfit + ".webp"
    Speaker "Even more dialogue..."
The variable needs to be one, the id of the picked outfit.
You simply attach that variable to the scene name, so the game will automatically read the correct CG depending on the picked outfit, without having to do an if check or use more than 1 line (which you'd need to type anyway).
So his CG folder would look like this, if he had 3 different outfits:

playerJumping_1.webp
playerJumping_2.webp
playerJumping_3.webp
playerRolling_1.webp
playerRolling_2.webp
...
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
Python:
scene ".../playerJumping_" + pickedOutfit + ".webp"
Unless simplification with the 7.6.x/8.1.x branch, this is incorrect. If you want to pass something else than an explicit displayable, you need to use the keyword:
scene expression ".../playerJumping_" + pickedOutfit + ".webp"

More globally, what OP is searching is the point 5 in that how-to.
 
  • Like
Reactions: Winterfire

peterppp

Active Member
Mar 5, 2020
762
1,347
No, you misunderstood my point. The idea is that he's making a western-style game with a CG every sentence (pretty much), so rather than a mess of "if" conditions, he writes the scene as normal, but taking an id (connected to a variable).

Of course if that's not the case, he can simply go for composite instead. I have no idea what type of game he's making, so I just assumed.


-edit-
"playerJumping" was just an example of one of the many scenes he could have, if we assume he's making a western-style VN:

Python:
label example:
    scene "playerJumping_" + pickedOutfit + ".webp"
    Speaker "Dialogue..."
    scene "playerRolling_" + pickedOutfit + ".webp"
    Speaker "More dialogue..."
    scene "playerDoesStuff_" + pickedOutfit + ".webp"
    Speaker "Even more dialogue..."
The variable needs to be one, the id of the picked outfit.
You simply attach that variable to the scene name, so the game will automatically read the correct CG depending on the picked outfit, without having to do an if check or use more than 1 line (which you'd need to type anyway).
So his CG folder would look like this, if he had 3 different outfits:

playerJumping_1.webp
playerJumping_2.webp
playerJumping_3.webp
playerRolling_1.webp
playerRolling_2.webp
...
i see, but then you could at least skip typing .webp the way i did it. but, unless i'm mistaken, you can skip the file extension altogether since the image will be found anyway
 
  • Like
Reactions: Winterfire

Likextra

New Member
Mar 3, 2022
3
0
No, you misunderstood my point. The idea is that he's making a western-style game with a CG every sentence (pretty much), so rather than a mess of "if" conditions, he writes the scene as normal, but takes an id (connected to a variable).

Of course if that's not the case, he can simply go for composite instead. I have no idea what type of game he's making, so I just assumed.
Hi thanks a lot!

It's a simple game where characters have different outfits and each outfit is a different png. I can't use composite because on each outfit the character's pose move !
It's not changing the outfit it's more like change the character's images.

This why I have some problems to make the game remember the choice of the player!
 

Winterfire

Forum Fanatic
Respected User
Game Developer
Sep 27, 2018
5,497
8,035
Unless simplification with the 7.6.x/8.1.x branch, this is incorrect. If you want to pass something else than an explicit displayable, you need to use the keyword:
scene expression ".../playerJumping_" + pickedOutfit + ".webp"

More globally, what OP is searching is the point 5 in that how-to.
Oh yeah, my bad, forgot about "expression"


Hi thanks a lot!

It's a simple game where characters have different outfits and each outfit is a different png. I can't use composite because on each outfit the character's pose move !
It's not changing the outfit it's more like change the character's images.

This why I have some problems to make the game remember the choice of the player!
Then the solution i've posted (with the added "expression"), or the one contained in the link anne posted are what you're looking for.