Help with gender, hair, eyes, and other basic customizing code

Hey guys, bit confused on how to connect this but here’s the problem.

With hair color of
*choice
#Black
#White

I created and labeled two variables which leads to a Male or Female version of styling your hair. If so how do I connect the hair color to one of these? If this is hard to understand, then what I mean is how do I make after choosing your hair color, what do I type to make it lead you to one of the options to style your hair depending on your gender? Such as if you choose black and you’re male you go to the male section, but if you’re female you go to the female section.

With hair color of
*choice
-#Black
—*set hair = “black”
—*if male
-----*goto blah
—*else
-----*goto blah2

-#White

Then do the equivalent for white hair.

This assumes that you have *created a variable called “male” that is true if male, false if not. Here are other ways of doing it, but this should get you started.

1 Like

Oh thanks for this. Sadly, I have not made a variable for true or false. Is there any other way or is this the only way? Will do this way if there’s no other option.

*choice
  #color1
    *set haircolor "color1"
    *if gender = "female"
      *goto female_hairstyle
    *if gender = "male"
      *goto male_hairstyle
  #color2
    *set haircolor "color2"
    *if gender = "female"
      *goto female_hairstyle
    *if gender = "male"
      *goto male_hairstyle

*label female_hairstyle
*goto next

*label male_hairstyle
*goto next

*label next

Remember to give the scene after hairstyling a label so both male and female versions can jump directly to it. You don’t want some players to run through the hairstyling scene they chose while other players run through both the scene they chose and the one they wished to avoid.

2 Likes

Thank you! This is what I was looking for.

Ah hey, sorry it seems I encountered an error. It keeps giving me an unexpected indent.
Trying to fix it and it gives me it is illegal to fall out of a *choice statement. :confused:

Perhaps paste your code here?

*choice
#Black
—*set Hair “Black”
—*if gender = “female”
-----*goto HairF
—*if gender = “male”
-----*goto HairM

Rest of the colors are like this also.

Are “male” and “female” the only choices?

For gender? Yes. I have not made a non-binary gender.

Try using an if…else structure rather than if…if.

Hard to say without seeing how you set up the gender choice, but I suspect choicescript thinks there is a possible answer to the question other than male or female.

Indentation needs to be consistent—so say you’re using two spaces, you’d need to use two spaces for one level of indentation, and then four spaces for two levels, six for three levels, and so forth.

Also, options need to be indented.

For your example above, you could try:


*choice
  #Black
    *set Hair "Black"
    *if gender = "female"
      *goto HairF
    *if gender = "male"
      *goto HairM

You can show indentation on the forums by clicking on the preformatted text button, which looks like </>, or by using three ` before and after your block of code.

Also, instead of

*if gender = "male"

You might want to use

*else

so that you can pass the autotests. As @Gower mentioned, the tests have no way of knowing that the only two options are ‘male’ and ‘female’ so that can make your game seem broken (as well as possibly introducing bugs when you have complex sequences with four or five possible states, instead of only two).

Also it’s probably better, I think, not to use capital letters in your variable names (so ‘hair’ instead of ‘Hair’ for instance).

3 Likes

You can test to see if the code is thinking there could be more than two options with this, and then running randomtest.


*choice
  #Black
    *set Hair "Black"
    *if gender = "female"
      *goto HairF
    *elseif gender = "male"
      *goto HairM
    *else
      *bug

1 Like

@Fiogan
Here’s my indents.
2 for black, 6 for set and 8 for goto.

*choice
  #Black.
      *set hair "Black"
      *if gender = "female"
         *goto HairF
      *if gender = "male"
         *goto HairM

@Gower I tried your coding and it gave me an it is illegal to fall out of a *choice statement.

1 Like

You’d need two for black, four for set, and six for goto—two spaces per level of indentation.

1 Like

I’m convinced there’s something wrong with the original bit where you set gender. How long is the code snippet in question? Can you put up the whole relevant chunk?

@Fiogan I redid the indents, but gives me an illegal error *choice statement.

@Gower Do you mean the text where you set gender? If so, here it is.

*label gender

*fake_choice
    #Son.
        *set gender "Male"
        *set He "He"
        *set Majesty "His Majesty"
    #Daughter.
        *set gender "Female"
        *set Majesty "Her Majesty"
        *set He "She"

Yep, it’s a capitalization error. When you *set gender, you used capital letters.

1 Like

Oh huh! You’re right. I just set it to lowercase and it worked. I only set it to a uppercase because during the gender stats it feels better to show a capital letter than a lowercase.

Is there another way to be able to show the gender stat word in upper case without messing up the code?

1 Like

You can capitalise the first letter of a variable’s value by using ! after the $ symbol.

So in this case, you would use $!{gender} to get “Male” or “Female”, and ${gender} would display as “male” or “female”.

3 Likes