#The Case Against Linebreaks
###The Problem
Now, as you write your game, you’ll probably notice that ChoiceScript uses a space between paragraphs rather than a first line indent (and if you’ve played ChoiceScript games on mobile devices you probably already know why that is). Additionally you might be able to understand why single line breaks in code don’t cause paragraph breaks (as a hint, try writing a paragraph where the second half is determined by a previous choice, without copying the first part). Finally we can use *line_break to cause a new line with no space, so that it doesn’t look like a new paragraph (the same as <br> in html).
Putting all together these are our options:
If we just move down one line in code we get a space, but no paragraph break. So this code:
red
rum
prints this:
- If we want a new paragraph, we move down two lines while coding. So this code:
red
rum
prints this:
- If we want a new line, but no paragraph break, we use
*line_break. So this code:
red
*line_break
rum
prints this:
However, there’s something I see done very commonly which is a mistake, which is spacing your paragraphs with double *line_break, so that your code looks something like this:
red
*line_break
*line_break
rum
which looks something like this:
Now, The Best in the Castle doesn’t do this directly. What I do see is a lot more of this (again, I’ve cropped the code to better highlight what I’m talking about):
"You won't have to come back here, if'n you don't want to."
He says with knowing eyes.
*choice
#That sounds nice.
[...]Or you could finally get away...
*goto dadhome
#But you can't.
[...T]here's your family to think about...
*goto dadhome
*label dadhome
*line_break
*line_break
But now is not the time to make decisions for the future.
You're still waiting on your father's promise.
*page_break
###Why It’s a Problem
There’s two reasons to avoid this. The first is very obvious, which is to see what happens when you make a mistake counting *line_breaks:
"You won't have to come back here, if'n you don't want to."
He says with knowing eyes.
*choice
#That sounds nice.
[...]Or you could finally get away...
*line_break
*line_break
*goto dadhome
#But you can't.
[...T]here's your family to think about...
*line_break
*line_break
*goto dadhome
*label dadhome
*line_break
*line_break
But now is not the time to make decisions for the future.
You're still waiting on your father's promise.
*page_break
[details=(It looks something like this:)][quote]The mountains are cold and craggy and dangerous. But it might be worth it, if the pay is good. And you are becoming quite proficient at hunting.
You could probably send the money back home. Or you could finally get away...<br><br><br><br>But now is not the time to make decisions for the future. You're still waiting on your father's promise.[/quote](And if you don't think that looks bad, try viewing it on a phone.)[/details]
The second reason not to is a bit more insidious, and harder to see, but gets to the heart of one of the things we mean when we talk about ‘code efficiency’. Code takes time to write. Every line is at least a few seconds. Likewise code takes time to read, again, only a second to skim those lines.
However, inefficient code takes more time. It’s longer to write (think of how many times you have different labels leading to new paragraphs. If your game is complex or long enough, you might be writing thousands of extra words. Then, once you’re reading it back, you’re going to have even more to go through. In the same vein, you might consider why we use paragraph breaks in the first place when writing. (You’ve probably seen a few people write a long post without them.) Simply put, you’re both going to spend less time coding and editing.
###The Solution
So, the solution is actually pretty simple. When you want to use a paragraph break, just use a paragraph break.
"You won't have to come back here, if'n you don't want to."
He says with knowing eyes.
*choice
#That sounds nice.
[...]Or you could finally get away...
*goto dadhome
#But you can't.
[...T]here's your family to think about...
*goto dadhome
*label dadhome
But now is not the time to make decisions for the future.
You're still waiting on your father's promise.
*page_break
If you add a few extras, it doesn't matter.
"You won't have to come back here, if'n you don't want to."
He says with knowing eyes.
*choice
#That sounds nice.
[...]Or you could finally get away...
*goto dadhome
#But you can't.
[...T]here's your family to think about...
*goto dadhome
*label dadhome
But now is not the time to make decisions for the future.
You're still waiting on your father's promise.
*page_break
Both cases will look the same in an actual game. ChoiceScript reduces all paragraph breaks down to one, the same way as it reduces trailing spaces down to one.
