Fixed a ChoiceScript bug: blank lines at the end of *if

choicescript-updates

#1

There’s been an annoying bug in ChoiceScript forever, like this:

Paragraph 1.
*temp maybe
*rand maybe 0 1
*if maybe = 1
    Maybe!

Paragraph 2.

If maybe = 1, then there’s a paragraph break between “Maybe!” and “Paragraph 2.” But if maybe = 0, then the paragraph break is skipped; the user sees “Paragraph 1. Paragraph 2.” all in one line.

I’ve just pushed a fix to github, so there will now always be a paragraph break.

Give it a try and let me know if it breaks anything.

In particular, I know people have been working around the bug like this:

Paragraph 1.
*temp maybe
*rand maybe 0 1
*if maybe = 1
    Maybe!
*comment endif

Paragraph 2.

Or like this:

Paragraph 1.
*temp maybe
*rand maybe 0 1
*if maybe = 1
    Maybe!
*line_break
*line_break    
Paragraph 2.

Both of those still work just fine; it’s just unnecessary.

If you actually wanted to show a paragraph only if maybe = 1, then you’d now do it like this:

Paragraph 1.
*temp maybe
*rand maybe 0 1
*if maybe = 1
    Maybe!
    *line_break
    *line_break
Paragraph 2.

New ChoiceScript features for programmers
Back from break, anything new? Changes in ChoiceScript?
#2

Nice. I went the double line_break route. It’s great to have this fix to avoid that since I usually don’t catch it until I’m testing.


#3

Yay from another double linebreaker…


Exploration choice loops
#4

Lol… I thought I was just noob using the double line_break. TY :joy:


#5

Double line breaks are showing up in my code as double spaces between paragraphs. One line break displays the way you’d think it should. Spaces between paragraphs do not display if the paragraph ends with an *if statement.

I have the latest version of Choicescript; am I missing something about how to fix this function? I didn’t have any issues with Monsters of New Haven High, but coding a new game with the latest version, I can’t seem to get a single blank line.

I’ll try the *comment workaround, but I’m hoping there’s a better solution that I’m failing to understand.


#6

I’m pretty sure everything’s working exactly the way it’s supposed to, but you may not like the way it looks.

*create leadership 50
*create strength 50

This
is
all
one
line.

This is a new paragraph.

And this
*line_break
is two lines.

Here's another paragraph.

This paragraph ends with a true *if statement.
*if leadership = 50
  Leadership = 50.

Here's the next paragraph, which ends with a false *if statement.
*if leadership = 40
  Leadership = 40

Here's the last paragraph.

Looks like this:

I would transcribe that as:

This is all one line.

This is a new paragraph.

And this
is two lines.

Here’s another paragraph.

This paragraph ends with a true *if statement. Leadership = 50.

Here’s the next paragraph, which ends with a false *if statement.

Here’s the last paragraph.

  1. Is that what you see as well?
  2. Is that what you’d expect? If not, what would you expect instead?

Text on the same line?
#7

With double line breaks, I’m seeing what you list under “looks like this”. I’m trying to make it look like “I’d transcribe that as.” Looks Like This has a smaller space between paragraphs than I’d Transcribe That As. I’m trying to standardize the size of the break between paragraphs whether or not the paragraph ends with an *if statement; with a double-line-break workaround those paragraphs are spaced twice as large as non-if paragraphs, and I’m reluctant to make them match by putting a double break between the unaffected lines.

If I’m understanding your example, the space in the code should just appear after the paragraph whether or not it ends with a true *if statement, since the bug fix? That is not happening for me. I have the latest version of ChoiceScript, and a blank line between paragraphs is not doing anything if there’s an *if statement there.


#8

I’m struggling to understand your question here. When reporting an issue, it’s important to provide three pieces of information in clear detail:

  • Steps to reproduce
  • What you’d expect to happen
  • What actually happens instead

I think you’re reporting two separate issues:

Issue #1) When you take my code sample above and use it, you don’t see “Looks Like This,” (my screenshot) and instead you see something else.

I claim that if you use my code sample, you will reproduce the exact same screenshot I posted here.

If that’s not true, can you post a screenshot showing exactly what you do see when you use my code sample?

(The best way to make sure you’re running the latest version of ChoiceScript is to archive and delete your old one; it’s very easy to download multiple copies of ChoiceScript and accidentally use the wrong/old version without noticing.)

Issue #2) Even if you did see the exact same thing as my screenshot, that’s not what you’d want it to look like. You’d want it to look different in some way.

But I don’t understand how you want/expect it to be different.

I really don’t understand what you mean when you say,

Are you saying that the transcript and the screenshot look different to you? They look exactly the same to me, except that the screenshot is in the “Georgia” font at 16px and the transcript is in the forum’s default “Helvetica” font at 14px.

In both the screenshot and the transcript, there’s just one blank line separating paragraphs. If the font is bigger, then the space between paragraphs is bigger, because one blank line is bigger.

*Note that issue #2 has nothing to do with if. If you use the following code sample #2, it’s guaranteed to look exactly like my screenshot, despite the fact that it has no *if.

This is all one line.

This is a new paragraph.

And this
*line_break
is two lines.

Here's another paragraph.

This paragraph ends with a true *if statement. Leadership = 50.

Here's the next paragraph, which ends with a false *if statement.

Here's the last paragraph.

If you want the screenshot to look differently (make it look more like the forum) then you’re talking about fonts, not about *if.


#9

Ouch. I understand entirely why you did this - having the blank space be associated with the next section (as you have it now) is far more intuitive than having it be associated with the *if statement (as it previously was).

But I’m really not looking forward to upgrading, because it will break the spacing in every *if statement I have. And there are, um, rather a lot of them.


#10

It would surprise me a great deal if you had to update a lot of *if statements. I ran a test on all of our existing games before rolling out this change, and found that 99%+ of *if statements did not need to change.

The only *if statements that do need to change are those that really want to have inconsistent paragraph spacing, where there would be a paragraph break if the *if statement is true, but no paragraph break if the *if statement is false. It’s pretty rare to want exactly that.


#11

I’m a troublemaker. > <

I’ll doublecheck, but I suspect that I have exactly this problem.


#12

Okay - I do have some cleanup to do, but it’s nowhere near as bad as I thought, now that I understand your explanation. Thank you for clarifying!


#13

Well, I’ve been using
*line_break
*line_break
to start a new paragraph. But I’ve also noticed a funny little thing CS does that I’ve been taking advantage of.

At the end of a sentence you type, if you add a single space, with the space bar.
The next sentence you begin, such as one under an *if statement, will have a nice regular sentence break between the two. However, when I tried adding a space on its own line under *if, with that same one-space-creates-a-space, instead, it adds a blank line. Grammatically frustrating. I’d like to find a way to just add a single blank space into the writing, sometimes, without adding a blank line.


#14

laughs maniacally Pretty rare, this one says… oh my. I’m glad I’m not using blank lines then. I’d be in big trouble. There are a lot of times I have another paragraph, or paragraph part, hidden under an *if.


#15

Ouch, I’m going to have to update about 50% of my code :dizzy_face:

This is going to be a looooong day…


#16

I’ve had similar issues as the other people that posted since me, but I’ll post code and a screenshot ASAP. It should be just a matter of taking out the *comment line and taking a screenshot.


#17

I bet you won’t have to update anywhere close to 50% of your game. No published CoG or HG game required that much updating.

This bug fix is extremely safe. If you think it involves changing all of your *if statements, then you’re probably misunderstanding what it does.

But the only way I can prove it is for you to try it on your own code. I think you’ll find that if your code was working correctly before, it will continue to work correctly after the bug fix, but if your code has buggy paragraph breaks before, it’s now fixed.


#18

That’s perfectly fine, and will continue working correctly after this bug fix.

For example, all of this code would work unchanged.

1) First paragraph.
*if maybe = 1
    Maybe paragraph.

    Another maybe paragraph.
*comment endif

Last paragraph.

2) First paragraph.
*if maybe = 1
    Maybe paragraph.

    Another maybe paragraph.
*line_break
*line_break    
Last paragraph.

3) First paragraph.
*if maybe = 1
    Maybe paragraph.

    Another maybe paragraph.
    *line_break
    *line_break
Last paragraph.

The only sample that would change is this one:

First paragraph.
*if maybe = 1
    Maybe paragraph.

    Another maybe paragraph.

Last paragraph.

I think you’ll find that if you had code like that, it was buggy before, and now it’s fixed.