*choice + two different *if variables


#1

Hello!

This weekend I’m working on familiarizing myself with CS so that I can finalize my formal pitch, and so far things are going swimmingly (at least, once I hammered gendered pronoun variables into my brain…). I have hit a snag that I can’t seem to solve, though.

What I want to do is give the player the option to select their name from three different options. The three options will be different depending on the gender of the player. In both cases, the fourth option will be a text entry field so that the player can enter their own name.

I’ve tried this two different ways, based on the information documents and other game startups that I was looking at for reference. I apologize in advance, because this is probably gonna be sort of spammy! The way it’s written in my document right now is:


*choice
     *if (gender="female")
          #Kelsey Hall
               *set name "Kelsey"
               *set petname "Kell"
               *goto TimePasses
		
          #Moira Hall
               *set name "Moira"
               *set petname "Mar"
               *goto TimePasses
		
          #Samantha Hall
               *set name "Samantha"
               *set petname "Sam"
               *goto TimePasses
			
          #None of these are your name! Your first name is...
               *goto input_name
		
               *label input_name
               *input_text name
               *goto nameconfirm

               *label nameconfirm
		
               Your name is $!{name} Hall, of course.
			
               *choice
                    #Of course.
                         *set name "$!{name}"
                         *set petname "sweetheart"
                         *goto TimePasses
                    #What? No it isn't! It's...
                         *goto input_name
	
     *if (gender="male")
          #Evan Hall
               *set name "Evan"
               *set petname "Ev"
               *goto TimePasses
		
          #William Hall
               *set name "William"
               *set petname "Billy"
               *goto TimePasses
		
          #Joshua Hall
               *set name "Joshua"
               *set petname "Josh"
               *goto TimePasses

          #None of these are your name! Your first name is...
               *goto input_name
			
*label TimePasses


This doesn’t work for reasons I think I understand – the *choice command is expecting a #choice in the next indented entry, no? But this is how I’ve seen it written on the wiki, a la this:


*choice
  *if (var)
    #This option 1
      *goto next

This isn’t the only/first way that I’ve tried this, though. I initially tried something like this:


*if (gender="female")

     *choice
          #female choice 1 as above
          #female choice 2 as above
          #female choice 3 as above

*if (gender="male")

     *choice
          #male choice 1 as above
          #male choice 2 as above
          #male choice 3 as above

And that did not work. If I remember correctly, it would display the female options for both genders, as though it wasn’t checking the male ones at all, which I thought might be the result of formatting. I did not know how to determine this, though I tried indenting and unindenting things fruitlessly. And frowning at notepad++ a lot.

The other option I tried after that didn’t work was this:


*if (gender="female")
     *goto femnames

*if (gender="male")
     *goto malenames

*label femnames

*choice
     #female choice 1 as above

…etc., with a separate *label for malenames, containing a separate *choice list. This also didn’t work.

Can anyone point to what I’m missing…? I’d be hugely grateful! Please keep in mind that I’m not a programmer and I’ve only been learning Choicescript since the start of the weekend, and use newbie-friendly words when you explain it to me, haha. Thanks in advance!


#2

Oh my god, it ate my formatting! I…don’t know how to fix that either. :frowning:


#3

put

pre
**codey stuff
/pre

except pre and /pre are surrounded by this <>


#4

Fixed your post. I’m going to have a look over it now.


#5

Oops! I guess I was fixing in there too. Thank you both very much!


#6

Where do you *set gender “female” or *set gender “male”. Do you have an example of the code for that? Is it above the previous picking names bit?


#7

I ran the first code through the IDE Tool it worked fine so maybe the error is coming from somewhere else. What type of error are you getting?


#8

It is above it, yes. It’s the first variable the player sets. I have

*create gender “”

set early on in the startup, and then later the gender setting bit looks like this:


*choice
	#Even this exhausted, you have the look of a woman who knows what she wants.
		*set gender "Female"
		*goto profession
	
	#Even this exhausted, you have the look of a man who knows what he wants.
		*set gender "Male"
		*goto profession

And oh my god I just noticed I had capitalized, is it case-sensitive oh no oh no. D:


#9

Yes if you have Male then you need Male, as male will not work.


#10

Welp, I feel like an idiot! I just went and plugged in the capitalized variables and boom, it works. I think I spent two hours fiddling with this, trying to make it work. I can’t believe I didn’t think to check/notice that. Sorry! But you guys did help me figure out what was wrong, so…mission success, I guess. :">


#11

Yeah capitals are important. it needs to be *set gender “male”


#12

Oops ha ninjaed! :slight_smile: It’s an easy mistake to make, you’re not the first and won’t be the last.


#13

It is alright I struggle alot with the code and the board has the best peps willing to lend a hand. \:D/


#14

I will definitely keep my eye out for that from now on! And yeah, I’m amazed at how quickly someone answered my thread. Thanks! :smiley:


#15

@sophistre Just a footnote to the above, really. It’s probably a good idea to generally use lower case for string variables, for precisely this reason, especially since ChoiceScript makes it very easy to capitalize either the first character or the whole thing when actually displaying the text it contains, as explained here:


#16

I think I originally changed it because I didn’t like it displaying in lower case on the stats page. When I finally found out about $!{} I didn’t even THINK to use it that way. That makes much more sense, thank you!