Is it possible to put an input_text into a multi-*choice?

I’m trying to make a multi-pick list using *choice. But as we go through, I also want to be able to ask for names.

I’m getting an indent error message when I try to send the name off, which makes me think this isn’t possible?

This code is incomplete but maybe you can get the idea of what I’m trying to do.

I don’t see any reason you couldn’t have input_text multiple times in a choice with lots of options, although it’s a little tricky for me to figure out what that codeish snippet is trying to do above–why some choices seem to repeat.)

You’ll have to show what indents you’re using, since it looks like that’s where your problem lies. I don’t think you’re having an *input_text problem at all. :slight_smile:

Use the words pre and post with < And > signs around them

pre (with signs)
*choice
#This option.
Blah blah
*goto elsewhere
#Maybe this one.
Something else
*goto wherever
post (with signs)

And it becomes this:

  
*choice
	#This option.
		Blah blah
		*goto elsewhere
	#Maybe this one.
		Something else
		*goto wherever
1 Like

After each *input_text, the next line should start with the new choice:

*choice
  #Mother
    What is her name?
    *input_text mother
    *choice
      #father
        etc
      #brother
        etc

However, there’s a better way to do it.

*label name_choice
*choice
  #Mother
    What is her name?
    *input_text mother
    *goto name_choice
  #father
    What is his name?
    *input_text father
    *goto name_choice
  #That's it
    *goto next_part_of_the_story

This will keep the code more compact so you don’t need to keep repeating yourself. However, it’s awkward as the player can type the name again and again. We can make it better still by using a variable for each choice and the *if command:

Create these variables in startup (feel free to change the names)
*create mother_no 0
*create father_no 0
etc

Then use this code:

*label name_choice
*choice
  *if (mother_no = 0)  #Mother
    *set mother_no +1
    What is her name?
    *input_text mother
    *goto name_choice
  *if (father_no = 0)  #father
    *set father_no +1
    What is his name?
    *input_text father
    *goto name_choice
  #That's it
    *goto next_part_of_the_story

Now the choices will not be visible once they have been used once.

Now, using these variables further, you can set a limit to the number of people that can be named, or you can make sure every person is named. You can also make sure that the player selects at least 1 (or two or however many) before they can click #That’s it. (I’m guessing you don’t want them to choose that before picking at least 1 name).

Let’s look at that last part, using all 6 choices:

*label name_choice
*choice
  *if (mother_no = 0)  #Mother
    *set mother_no +1
    What is her name?
    *input_text mother
    *goto name_choice
  *if (father_no = 0)  #father
    *set father_no +1
    What is his name?
    *input_text father
    *goto name_choice
  *if (guardian_no= 0)  #Other guardian
    *set guardian_no +1
    What is their name?
    *input_text other_guardian
    *goto name_choice
  *if (sister_no = 0)  #Sister
    *set sister_no +1
    What is her name?
    *input_text sister
    *goto name_choice
  *if (brother_no = 0)  #Brother
    *set brother_no +1
    What is his name?
    *input_text brother
    *goto name_choice
  *if (someone_no = 0)  #Someone else
    *set someone_no +1
    What is their name?
    *input_text someone_else
    *goto name_choice
  *if (((mother_no + father_no)+(guardian_no+sister_no))+(brother_no+someone_no)) >0 #That's it
    *goto next_part_of_the_story

Now, the player can choose as many names as they like. They can’t choose ‘That;s it’ unless they have chosen at least 1 name. I hope this helps.

1 Like

I just tested this, and <post> did not end the preformatted section I started with <pre>—it continued in preformatted mode until I replaced <post> with </pre>. To make the greater-than and less-than signs visible, I’ve placed a backslash ahead of each one. In my view, what I’ve typed looks like this: \<pre\>, \<post\>, and \</pre\>.

I personally type my preformatted code here using backticks. They look like this: ` , and are on the same key as the tilde ( this squiggly thing: ~ ) on all four physical keyboards I can spy on. Three Windows, one Mac, if it matters.

That said, the iPad’s touchscreen “keyboard” doesn’t have an obvious way to type a backtick, so <pre> and </pre> will be very useful if I ever get it in my head to post from a mobile device.

Thanks for the tip. I can’t imagine how much I would’ve frustrated myself if I’d tried to post from mobile using backticks.

2 Likes

On a mobile, or even a PC, just click the </> symbol and type your code. That symbol takes all the worries away - no need for anything else :slight_smile:

2 Likes