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.
label chara_select:
whc "Are you a girl or a boy?"
menu:
"Girl":
$ girl = True
$ boy = False
jump start_2
"Boy":
$ boy = True
$ girl = False
jump start_2
label start_2:
if girl:
#PERRY, FEMALE
image p1 = "TEST_CHARA_2.png" #not done yet
image p2 = "perry_fem_sad.png"#not done yet
image p3 = "perry_fem_hurt.png"#not done yet
image p4 = "perry_fem_happy.png"#not done yet
image p5 = "perry_fem_angry.png"#not done yet
image pa1 = "perry_arfem_shocked.png"#not done yet
image pa2 = "perry_arfem_sad.png"#not done yet
image pa3 = "perry_arfem_hurt.png"#not done yet
image pa4 = "perry_arfem_happy.png"#not done yet
image pa5 = "perry_arfem_angry.png"#not done yet
if boy:
#PERRY, MALE
image p1 = "perry_male_shocked.png"
image p2 = "perry_male_sad.png"
image p3 = "perry_male_hurt.png"
image p4 = "perry_male_happy.png"
image p5 = "perry_male_angry.png"
image pa1 = "perry_armale_shocked.png"
image pa2 = "perry_armale_sad.png"
image pa3 = "perry_armale_hurt.png"
image pa4 = "perry_armale_happy.png"
image pa5 = "perry_armale_angry.png"
show p1 at left with dissolve
p "This is so weird."
jump start
But it just defaults to Male Perry when I select GIRL. I sort of think I know what is going on, but Male Perry's images are all separated in their own block. So I'm a little confused. Help?
Maybe try to have start_2 jump to a different label depending on the variable. It's possible it's just running through both if statements because there is no break between them and it's overlapping with the last things you changed. So if girl: jump girl_label or something like that and separate them and make sure that the label jumps somewhere else at the end instead of running through continuously. I hope this makes sense. I mean, I KNOW that it shouldn't run the if statement if it's false but just in case it's a problem..
It also could help to put an else statement instead of two if's. I'd try that before anything else.
On another note, it may feel more organized/simpler to have one variable called gender and have it set to 0 or 1 for girl and boy. That's what I've done. But it's just a thought. So you don't have to change two variables. Just one.
Hmmm...
yeah I guess just try if gender == 0, etc.
I'm trying to think of what else it could be. For my two genders, I don't change the definition of a lot of images, I have an if statement inside of a composite. Instead of in a label. So the composite is either going to show girl pieces or boy pieces depending on the variable.
I may have even assigned them to their own composites though. I'm not sure.
*edit: I'll try to put together an example when I can and post it here. I'll test it and make sure it works.
I *really* do not want to have to do if/then for the start of every single scene. Well, I could BUT I also have five expressions for each gender version. I also wanted to do alt-outfits for each party member. Grrrrrr.
label chara_select:
whc "Are you a girl or a boy?"
menu:
"Girl":
$ girl = True
$p1.image = "TEST_CHARA_2.png" #not done yet
jump act1_start
"Boy":
$ boy = True
$p1.image = "perry_male_shocked.png"
jump act1_start
And the scene plays, but I get this:
If I can just figure this one out, it would work, except I have multiple outfits and expressions that I would like to include as well. I guess I *could* give everything its own name, but that's pretty much a non-starter.
This is the big issue, if statements! A beginner of python! Some people forget this, even I do sometimes.
If's are to be followed either by a elif or else statement!
Change your second if to an else! Post your update here and we'll buff this out!
I also recommend placing them in an Init: block. Since they are dealing with images in different formats. To be honest, the easier solution, is just defining the characters and placing their "default" image in. Then define each image separately to use later (with different names of course).
While I don't know anything about the method you tried the second time, I can tell you what's happening with your first attempt to set the images. `image` statements are always run before the game starts, so whichever one is furthest down in the file, no matter what, is the one that will stick - That's why in your case, the later male images are used, regardless of the variables' state.
Nightglove Institute - Kidnapped students, forced to train to be secret agents and assassins! Monstrata Fracture - Date cute monsters! But will you risk destabilizing the human plane of existence?
valeatory wrote:While I don't know anything about the method you tried the second time, I can tell you what's happening with your first attempt to set the images. `image` statements are always run before the game starts, so whichever one is furthest down in the file, no matter what, is the one that will stick - That's why in your case, the later male images are used, regardless of the variables' state.
I also recommend placing them in an Init: block. Since they are dealing with images in different formats. To be honest, the easier solution, is just defining the characters and placing their "default" image in. Then define each image separately to use later (with different names of course).
I would if I was dealing with just one character image, and especially if I was not trying to do alt outfits as well (for every party member).
valeatory wrote:While I don't know anything about the method you tried the second time, I can tell you what's happening with your first attempt to set the images. `image` statements are always run before the game starts, so whichever one is furthest down in the file, no matter what, is the one that will stick - That's why in your case, the later male images are used, regardless of the variables' state.
I was saying to put the if/else statement in a live composite. If you don't know what that is, it's pretty easy to google, just include ren'py in the search. The live composite will show certain images as layers to create your sprite as a whole but you seem to have just one flat image for an entire sprite with an expression which is fine too. You could just make a composite (idk if it's the best for one layer) of your one sprite and have it set up to where the image changes depending on a variable - something like "myimage_%d.png"%(expression)
This basically takes the variable called expression and changes the %d of the filename part to whatever the variables value is. Does that make sense? Then you have an if/else statement in your composite to determine which file will be shown. the boy one or the girl one. And I will go ahead and try to make a simple example that works for you if you still haven't found a decent way that works. I've just been a little busy today sorry! My way might be more complicated than it needs to because I'm used to live composites and dealing with layers and variables because I need to do it a more complicated way but I'll keep it as simple as possible while doing a way I'm familiar with that I KNOW works. and should be fairly easy to understand/learn.
Those these guys are right. If/elif/else is important. That's why I mentioned just trying the else but I think you said that didn't work. Also, it could be true that using 'image' in a label might not work too well. This is not a very good way to go about things. So we'll get this sorted out as smoothly as possible.
If you use a live composite (like I'm going to show you) then you can just change a variable (for the expression of your sprite) to change if your sprite is sad or happy etc. You wouldn't have to hide a happy sprite then show a sad sprite. It would be an instant change with a $ my_expression = 2 for sad etc
Bryy wrote:
Why would I still need to make two character files?
I'm not sure entirely what you mean by that. Do you mean that you need an image for a girl and an image for a boy? Or something else? It seems to me like you already have two sets (one for each gender) of many more than two images each. If you wanted to use DynamicImages in the code you had already posted, it might look something like this:
default gender = "fem" #or "male", if you prefer
image p1 = "perry_[gender]_shocked.png"
image p2 = "perry_[gender]_sad.png"
image p3 = "perry_[gender]_hurt.png"
image p4 = "perry_[gender]_happy.png"
image p5 = "perry_[gender]_angry.png"
image pa1 = "perry_ar[gender]_shocked.png"
image pa2 = "perry_ar[gender]_sad.png"
image pa3 = "perry_ar[gender]_hurt.png"
image pa4 = "perry_ar[gender]_happy.png"
image pa5 = "perry_ar[gender]_angry.png"
label chara_select:
whc "Are you a girl or a boy?"
menu:
"Girl":
$ gender = "fem"
jump start_2
"Boy":
$ gender = "male"
jump start_2
label start_2:
show p1 at left with dissolve
p "This is so weird." #should have the image of the correct gender
jump start
You would need to rename your test image to fit your later pattern of "perry_fem_shocked.png", and I am not sure if using so many DynamicImages would be less efficient than another solution (Like LiveComposite, which it seems others know more about), but it should work and make for readable code.
I would also recommend renaming your image variables, though, to something more descriptive, like `perry shocked` instead of `p1`, for the sake of your ease of writing later.
Nightglove Institute - Kidnapped students, forced to train to be secret agents and assassins! Monstrata Fracture - Date cute monsters! But will you risk destabilizing the human plane of existence?
That's closer, but you don't actually need to define the images twice. If you look at the lines you're putting in after `gender="male"`, they're the same as the ones before it. All of those (as well as the `gender="male"` line) are not necessary, since the images will automatically update when you change gender later in the menu.
Basically, just try the code I posted and see how it goes.
Nightglove Institute - Kidnapped students, forced to train to be secret agents and assassins! Monstrata Fracture - Date cute monsters! But will you risk destabilizing the human plane of existence?