Indentation

So, for indentation, when you have a group of nested choices, then you move to another choice that is no longer in that group. How does your indentation work?
I know you go up 1 level each line from a choice, so say you have choice, then #, you go up 1 level for the next line, then keep that level tell the next option, or choice.
However, I am not sure what you do when you want to go to a different choice, such as a different path. The Wiki, and that guide I was given the link to, thanks by the way, does not seem to provide as much help as I would wish.
So, would someone be able to assist me? It seems so far, that indentation is my largest hurdle for makeing my choice games. Everything else I have looked at so far seems… Relativly simple, and streight forward.
Anyway, I hope that all who look at this new topic have a nice rest of the day, and weekend. Supposed to be nice tomorrow.

I think this fits better in the choice script help category than the general category, so I moved it.

3 Likes

Roughly my script goes like this

label one

blablablablabla

choiceoption1a:
choiceoption1b:
choiceoption1c:

if choice1a: blablablabla
set stat one
goto label two

if choice1b: blablablabbla
set stat two
goto label two

if choice1c: blablabla
set stat three
goto label two

label two

blablablablablabla goes the blacksheep.

choiceoption 2a:
choiceoption 2b:
choiceoption 2c:

and so forth… (proper formating in your text editor/tool being done)

If you have not yet looked at CSIDE, I’d suggest doing so – it is a tool that helps you keep track of indents and flow of your script. It is an invaluable tool that I am eternally grateful to @CJW for.

1 Like

I have been taking a look at CSID, but I couldn’t find a good user manual on how to manipulate it properly.
Either the manual that came with it was not very extensive, or something was stopping me from getting to the rest of it. The read me document.

I’m not entirely sure what you’re asking, so let me see if I get this right. Are you trying to nest a choice inside a choice and need help figuring out the indentation?

*choice (indent level 1)
  # option (indent level 2)
    lots of stuff in here (indent level 3+)
  # option (indent level 2)

outside of choice (indent level 1)
1 Like

Yes, sort of.
I nested a choice inside a choice, then a choice in that one, then I went on to another path that can be taken that is supposed to show up at the primary, so you go to attack a town, then you figure out what to do to attack the town, then you figure out what you want to send, then the next choice is instead of going to attack the town, you go to the forest and try to get stuff there.
Also trying to figure out the CSID program, since people keep saying it’s good but I can’t get a good user manual on how to work it properly. Apparently it’s supposed to be good when having difficulty with indentation and stuff.

Okay, I’m not entirely sure if this is what you want because I still am not entirely clear on what you’re saying, but how’s this?

*temp attackchoice 0

*choice
    #I want to attack the town.
        How do you want to do this?
        *choice
            #Direct attack with my army.
                *set attackchoice 1
                Are you going to gather supplies in the forest?
                *choice
                    #No, we have enough.
                        *goto attacktown1
                    #Yes. We're not prepared.
                        *goto gathersupplies
            #Sneak in during nightfall and destroy the town's resources.
                *set attackchoice2
                Are you going to gather supplies in the forest?
                *choice
                    #No, we have enough.
                        *goto attacktown2
                    #Yes. We're not prepared.
                        *goto gathersupplies
    #I want to do something else.
        *goto somethingelse

*label gathersupplies
You gather supplies.

*if attackchoice = 1
    *goto attacktown1
*else
    *goto attacktown2

*label attacktown1
You rush the town with your army and destroy them.
*goto done

*label attacktown2
You sneak into the town at night and destroy their food supply. They surrender in the morning.
*goto done

*label somethingelse
You leave the area to go do something else.
*goto done

*label done
And you're done!

CSIDE is incredibly useful for indentation, but it still requires some regular know-how of Choicescript and how to write it. CSIDE’s auto-indentation is great, but more complex indentation requires a bit of manual tinkering. The program is basically an amplified version of Notepad++ that comes with built-in testing and some bells and whistles that let you focus more on writing than coding, but you still need to become familiar with Choicescript to sufficiently create a functioning game. Don’t expect CSIDE to write your coding automatically or to get everything correct 100% of the time. Coding games like this is tough work that requires practice.

3 Likes

I have a decent understanding of choice script, it’s just that the indentation is messing me up. I definitely have enough time to practice, given that the whole virus thingy.
Also, I assume that you use for spaces per level for indentation? I’m assuming so, from the snippet of code that you gave me.

I did in this post, but whether you use spaces or tabs in your actual code is up to you. CSIDE allows you to use either spaces or tabs; you just have to change the settings and every indent you make will turn into whatever you selected. I use tabs in my code, and I made the code in my post look like tabs using spaces, but if I posted that code into one of my project, I’d have to correct the indentation ti make it function. The important part of indentation is to keep it consistent throughout. If you start with indentations of four spaces, keep doing that. Otherwise, you run into errors.

To expand on @will’s example

*choice
   #OptionA
      *choice
         #OptionA-A
         #OptionA-B
   #OptionB
      *choice
         #OptionB-A
            *choice
               #OptionB-A-A
               #OptionB-A-B
         #OptionB-B

Treat each choicebody as if they’re on its own container-vessel, then you stack them up on each other. Kinda like Matryoshka.

2 Likes

I think I understand…
Regardless of weather or not you ident the actual *choice command, think I will, just so it makes it easier, each number option is indented up 1 level, then when you want to go back to another choice, you go back to level 1. In my case, 1 tab.
Still not totally sure why I keep only getting 1 choice when I set up 3, but…
Am I heading in the correct direction?

This will be helpful if you can show the code in question. Mind posting it here? The entire choicebody.

2 Likes

Here is the code:

		You call your troops forward to begin the march. However, what exactly do you want to do?
		*choice
				#scout the town for further infermation. this way, you can find out if there are any nasty surprises hidden for you.
					However, if you do this wrong, your troops will be noticed, and the town will be on watch.
*Choice
					#Just martch your troops all down there, you can kill 200 people with your army.
							Again, there may be wrisks in this action.
	#Send your forces into the forests around town to harvest the bounty of corpses located in their depths.
		You call your forces, but what do you want to send?
			*choice
			#Send Skeletons
				#Send Zombies
					#send both
						You enter the forest, your troops fanning out to find animal corpses, and any others that are around.
							Up ahead, you see a wolf pack. There are perhaps 10 of them, although they have not noticed you yet. Or, they don't consider you a threat.
							"Choices, choices... The floating head chirps. What to do, what to do...
*choice
		#order your troops to kill the pack, then raise them into your army.
			#atempt to skirt the pack.
				#Just march right past the pack, not attacking.
							*if_send_zombies
										The pack hears your zombies, and turnes to attack you.
*choice
	#rade the local graveyard for the required raw meterials.
		You enter the graveyard, the gates squeaking open as you do. There are rows apon row of gravestones, from the simple, to the elaborate.
		However, before you get too far, you see a gravekeeper. Se has not spotted you yet, so you have a choice to make:
			*choice
				#hide yourself and your troops from her.
					#kill her and raise her into a white letting her assist you.
						#leave the graveyard and try another way.

I got tired of hammering the space bar, so decided to use tabs. I hope that the fact that I think each tab is currently, 8 spaces now? does not impact the indentation at all. I would like to get each tab down to 2 spaces, just because, but…

Hm, no code preformat. Regardless, I think your scene is waaaay too complex for you to attempt it using purely indentation. I suggest chunking them up a bit using *label-*goto.

You call your troops forward to begin the march. However, what exactly do you want to do?
*choice
	#scout the town for further infermation. this way, you can find out if there are any nasty surprises hidden for you. However, if you do this wrong, your troops will be noticed, and the town will be on watch.
		[text here]
	#Just martch your troops all down there, you can kill 200 people with your army. Again, there may be wrisks in this action.
		[text here]
	#Send your forces into the forests around town to harvest the bounty of corpses located in their depths.
		You call your forces, but what do you want to send?
		*choice
			#Send Skeletons
				[text here]
			#Send Zombies
				[text here]
			#send both
				You enter the forest, your troops fanning out to find animal corpses, and any others that are around. Up ahead, you see a wolf pack. There are perhaps 10 of them, although they have not noticed you yet. Or, they don't consider you a threat. "Choices, choices... The floating head chirps. What to do, what to do...
				*choice
					#order your troops to kill the pack, then raise them into your army.
						[text here]
					#atempt to skirt the pack.
						[text here]
					#Just march right past the pack, not attacking.
						*if send_zombies
							The pack hears your zombies, and turnes to attack you.
						*else
							[text here]
	#rade the local graveyard for the required raw meterials.
		[text here]

This is, I believe, what you were trying to achieve. (Accidental rhyme lmfao.) Just for future reference: all options in one choice tree must be on the same line. I do agree with Szaal that this is a bit too complex and it might be easier to use *goto and *label to make this a bit more manageable.

Yes, I think you might be right about the labels at least, depending on what level you go for indentation after the “go to label command. At the very least it should make things a little bit more manageable.
I’m not exactly sure what you mean about, all choices in the same tree must be on the same line?
I am assuming it’s literal, but I’m not totally sure. I am beginning to realize that with this kind of stuff, it Hass to be extraordinarily exact.
Also, what’s the indentation for labels? Started playing around with them about an hour ago to see if I could get the whole thing to work, because somehow I managed to get the option of taking my troops into the forest from the main choice, to a secondary choice in the “assault the town, tree. Still not quite sure how that happened.
I think it had something to do with me altering the tabs and such, though when I try to put in a another choice to differentiate it, I kept getting errors about a choice body.
Thank you all for all the assistance that you have been providing me with this so far.

1 Like

This is a choice tree:

*choice
	#Option 1.
		Text for option 1.
	#Option 2.
		Text for option 2.
	#Option 3.
		Text for option 3.

As you can see, every #option is on the same indentation level (in this instance, 1 tab). The text for every option is on the next indentation level (2 tabs). This is how the indentation works in Choicescript. Every time you add a *choice command, the indentation needs to match this structure. For example, for a choice nestled inside a choice, you’d do this:

*choice
	#Option 1.
		Text for option 1.
		*choice
			#Option 1a.
				Text for option 1a.
			#Option 1b.
				Text for option 1b.
			#Option 1c.
				Text for option 1c.
	#Option 2.
		Text for option 2.
	#Option 3.
		Text for option 3.

The indentation for *labels varies depending on where you place it. The *label command (and all other commands) need to match the indentation where they’re placed. Here’s an example:

*label textbegin

This is where the text begins.
*choice
	#Option 1.
		*label option1text
		Text for option 1.
		*goto end
	#Option 2.
		Text for option 2.
		*goto option1text
	#Option 3.
		Text for option 3.
		*label option1check
		*if option1
			*goto option1text
		*else
			*label failoption1
			You are not going to the text for option 1.
			*goto end

*label end
This is the end of the text!

You are correct that indentation has to be exact. It’s the only way the parser can read your commands and correctly display your game.

2 Likes

Treat label just as you would a normal text, as well as the *goto.

That makes sense. The labels aren’t commands, they are reference points. Thank you :slight_smile:
I’m actually not quite sure why I’ve seem to be getting this error:
Start up line 32, it is illegal to fall out of a star choice statement, you must either star go to, or star finish before the end of the indented block.
At the moment, start up line 32 is the third choice about wanting to send skeletons, zombies, or both. The indentation is all the same, and putting in, or removing a choice command at the top of the three choices doesn’t seem to make a difference.
I looked at the Arror dictionary on the choice script wiki, and this one does not seem to be there.