Trying to Make choices

Hi there, so I started trying to teach myself choice script recently and I am picking away at coding the stats page I was experimenting with how I would code a choice that set an actual variable such as gender? What I have right now is really simple but it’s more than anything me trying to get the idea of how to code it since I’m a hands on learner. It works in setting the gender in the stat page but I keep getting a bad label error.

*label gender
What are you?
*choice
  #Male
    *set Gender "Male"
    *goto Male
  #Female
    *set Gender "Female"
    *goto Female
*if Male
Handsome chap ain't yah?
*Choice
  #Of course I am.
      You wink at the dorky author
*finish
  #Don't be Ew.
      Jess Stawp
*finish

I was wondering if anyone can tell me where I went wrong? Sorry if it’s a stupid question!

When you say *goto, you are telling the script to look for that label.

In the code you provide, there is a label “gender” but there is no label “Male” or “Female”.

3 Likes

Ooooh so where I have “if” I should put “lable”?

Yes, if male should be changed to *label male. “If” is to check what a variable is set to, which you can use to display different text or send things to different labels later.

That will make your code work, except that any *choice needs more than one #option below it.

Any time you use an *if, the line under it needs to be indented. If you change it to a label, though, you’re good there too. The lines after the first “finish” won’t work until you add a label female and another choice command, plus again, more than one option.

Be really careful about capital letters. Now that you’ve set it to “Male” and “Female”, your code won’t recognize “male” and “female”. Same with scene names - if you say goto_scene Party and your scene is named party, it won’t find it. When I first started coding, I really quickly learned to only use capital letters if I was telling the game to remember a name.

1 Like

Oh - one more thing. Any *choice command needs to have a goto at the end of each option, or else it will break the game. If you don’t actually need it to do that, you can use *fake_choice instead.

2 Likes

Oh! That makes a lot of sense! I kept wondering where it was getting lost at! =D I just tested it out and I got the Male choice working and was able to make a choice that had text that followed it! Yay! progress! Thank you guys a lot! I was going to OCD about that all night. XD This is fun to learn but frustrating all at once.

1 Like

When frustrated with code, I remember this:

2 Likes

Sashira is right about *fake_choices
They are very handy and don’t let the name fool you they’re just easier than normal choices. They run smoother if you’re going down the line.

Use the *choice function when you want to jump to different blocks of text. Say choices lead you to different places.

Also you can hide if statements inside your choices say you were adding builds. This way you can group your story under your choices for sheer organization purposes.

*choice
#male
* if small
(Text here)
*set male
*goto (pick a label)

1 Like

Ooooh okay! That might help me keep up with the code, I’m trying to make notes in my story plot journal to keep up with what does what (or at least what I hope will do what.) I might be a little too ambitious for my first shot at making a game.

I was just thinking about how I was going to incorporate height and build to try and customize a bit. (might mean I have to write the same scene three times but it might end up being rewarding for all involved.)

Thank you so much for showing me how to incorporate that!

I might have to play with coding Fakechoice, if nothing else it would be a good way to give people options how to react but not be too much to keep up with.

1 Like

The fun thing about *if statements is that you can stack them. An *if within an *if as long as you indent. BUT start light.
And the fun thing is all false *if statements are invisible so one choice can appear in so many different ways. As you’ve seen with my WIP.

1 Like

Will do! It wouldn’t do me any good to scare myself by having like six layers of *if before I even have a handle on how to do a one *if

Huh so would *if work to recall a previous choice? Like Say MC threw a drink in character A’s face, would it work if I put *if Drink throw, work and use *label Drink Throw after the referenced choice?
Yup! Yours is one of the levels of coding I look up to, especially in the customization range! Like you have insane amounts of customization, I’m hoping to do something similar on a smaller scale once I get the hang of this. X3

I think false *if is going to be my new coding best friend. Especially if I go through with the multiple choice of demon species instead of trying to choose one/come up with a vague enough one that people will be mostly okay with. (I’m already mentally preparing myself that people aren’t going to be happy with some plot necessary things I’m planning out.)

1 Like

*labels are attached to *goto only

So I’m assuming you know how to create variables. You’ve got to set a False *if TRUE before it becomes visible.
Long story short you’re building on and off switches for your *if statements into your story with TRUE false variables
*label bar
*if drink_throw

So if a variable is
*set male true

When ever “*if male” us used it shows up.

1 Like

Just wanna say something about *fake_choice here.

*fake_choice inside a *fake_choice (nested *fake_choice) doesn’t work properly. You may still need some *goto at here or there.

1 Like

When doing *if values, it is best to have it look something like

*if (gender = "Male")

it keeps the code clean and confuses the system less. I’m not sure why, but sometimes the engine just does not like *if statements. They’re very…iffy :wink: :wink: :wink: :wink: (i crack myself up)

In addition, it looks like your spacing might be slightly off – are you using a mixture of tabs and spaces? I would definitely do one or the other. Either that, or the forums are making everything look wonky, today.

In addition, in your code, you have further spacing issues –

when not double spacing or *page_break ing, I’ve noticed that choicescript sometimes reads *if incorrectly. This is completely ignoring that you should have used a *label – I’ll get to that point in a moment. It happens a lot when creating complex stats screens (lord, was ~that~ a fun learning curve). *if is a very complex part of the code, in that the system can break completely if the spacing isn’t exactly right – even if it ~looks~ right (IE: you’re using the correct number of tabs, but for some reason are still getting an error – this is due to needing a blank line or two before your *if statement)

now, as for *label, it should always have the same spacing as your previous *goto (or the previous line. my *labels are usually right after a *goto) – otherwise, the engine doesn’t read it and produces an error.

and, btw, using true/false for gender is just going to piss you off. It’s way easier to use “” statements, so that you can do something like

It wouldn't surprise you if it was one of the younger...
*choice
 #boys you room with.
  *set gender "male"
  *set twinname "Marlon"
  *set their "his"
  *set theirs "his"
  *set them "him"
  *set they "he"
  *set themself "himself"
  *set child "son"
  *set mister "mister"
  *goto orphanintro2

in the above, any time you use ${they} it would show up as “he” instead. This way, you don’t have to write the same passage 3+ times to provide for each gender :slight_smile:

1 Like

All this is well and good, but I feel like the things that helped me the most while doing my game so far has been visuals and learning with them. Namely the guide by RE Towers and this second one by I think @FairyGodfeather. I will link both as always. It is my policy to give as many people the links so it’s easier for them in the future:

Link 1: https://retowers.neocities.org/CSGuide/CSGuide.html

Link 2: A Basic Tutorial on Name, Relationship and Gender Variables

I live for both of these.

Edit: I notice you are talking about *if statements so I’ll include my favorite thread about that.

Here: *if - *if versus *if - *else/*elseif
It might be a bit confusing so I’d read through the entire thread a few times, but I haven’t had an *if issue since.

4 Likes