intfiction.org

The Interactive Fiction Community Forum
It is currently Sat May 18, 2013 1:05 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sun Aug 07, 2011 12:19 pm 
Offline
User avatar

Joined: Sun Feb 03, 2008 5:55 am
Posts: 298
If there is one thing I do not get in Inform 7 right now, it is line breaks. Here is how I am working at the moment:

1. Write text.
2. Run it.
3. Note where line breaks appear.
4. Add [line break] or [no line break] as appropriate.

Take the following example:

Code:
The garage is a room.

The block is in the garage. The block can be this way or that way. The block is that way.

Carry out pushing the block:
   say "First sentence.[if the block is that way] Second, conditional sentence.[end if]";
   rule succeeds.

This produces the following output:
Quote:
>push block
First sentence.
Second, conditional sentence.

Nothing obvious happens.

Okay, noobishness, I don't know why that "Nothing obvious happens." is there, because I thought "rule succeeds" should stop that, but let's ignore that. I have two questions about this code:

1. How do I fix this? I have tried any combination of spacing, moving full stops, swearing - and I can't make the text output look right for both conditions. To clarify, I want the first and second sentences on the same line.

2. Why in the name of sweet flying kittens would I possibly want output like that? What is the utility of this feature? Why does Inform want to insert newlines all over the place - not even paragraph breaks, but newlines!

On a related note, why does the IDE indent text within indented blocks of code? It may make it look legible in the editor, but the text then line breaks and indents all oddly in the game.

In short, why does Inform want so much to make me look bad? I understand that some people will need fine control over line breaks and spacing. That's fine, give them the option. But why on Earth can't I7 just, by default, assume that I want block paragraph spacing, between paragraphs that I have specifically requested, and no crazy indentation.

Or, in other words, why can't it just be like TADS 3, where I never had to worry about any of this stuff, where you get paragraphs and newlines when you ask for them, where everything is single spaced by default, where even if your conditional text mistakenly spews out multiple new paragraph tags you still only get one. You know, an intuitive environment for outputting computer-generated text, where rather than getting a headache over complex logic puzzles (how do I make sure this sentence ends in a full stop? if this condition is false will that space trigger a newline? if the middle clause isn't displayed, will I have too many spaces?), I can just bloody write.


Top
 Profile Send private message  
 
PostPosted: Sun Aug 07, 2011 12:54 pm 
Offline
User avatar

Joined: Sun Feb 03, 2008 5:55 am
Posts: 298
Having de-stressed a bit, I came up with:

Code:
Carry out pushing the block:
   say "First sentence. [if the block is that way]Second, conditional sentence.[otherwise][line break][end if]";
   rule succeeds.

I still challenge anyone to tell me that this is intuitive.


Top
 Profile Send private message  
 
PostPosted: Sun Aug 07, 2011 2:50 pm 
Offline
User avatar

Joined: Fri Jan 07, 2011 1:19 pm
Posts: 146
Location: USA
Ah man, that sort of thing drives me INSANE.. especially when working with a project that takes a long time to compile just to see if you got the break right.


Top
 Profile Send private message  
 
PostPosted: Sun Aug 07, 2011 3:32 pm 
Offline

Joined: Wed Jul 06, 2011 7:44 pm
Posts: 15
This drives me nuts too. My code always ends up with a crazy mishmash of simple punctuated texts, [line break], [no line break], [run paragraph on], and [command clarification break] (this last one in contexts that have nothing to do with clarifying commands; it just seems like the only way to get the spacing I want sometimes.)

One thing that I picked up from Section 5.8 of the docs that helped a little is the fact that Inform adds an automatic paragraph break between two texts that are printed by different rules, but not if they are simply printed by different phrases. But I still don't understand the line break system fully, and like you, I end up doing a lot by trial and error.

Since this is something I've been meaning to figure out anyway, I'll run some sample code and try out all the permutations of different break types and where they appear (internal to a line of text, at the end of a line of text, as the last text produced by a phrase, as the last text produced by a rule, etc...) I'll see if I can boil the whole thing down to a logical set of rules, and let you know if I have any luck.


Top
 Profile Send private message  
 
PostPosted: Sun Aug 07, 2011 4:01 pm 
Offline

Joined: Sat Jan 23, 2010 4:56 pm
Posts: 2081
For this case, I always do:

Code:
Carry out pushing the block:
    instead say "First sentence[if the block is that way]. Second, conditional sentence[end if].";


This provides the correct result with the minimum of cruft.

The crucial observation is that I7 goes newline-happy if a period is immediately followed by an open-square-bracket. In your second example below, you got a space in between the period and the bracket, which is why it started behaving the way you wanted.

Quote:
On a related note, why does the IDE indent text within indented blocks of code? It may make it look legible in the editor, but the text then line breaks and indents all oddly in the game.


The IDE expects you to only hit Enter inside a quoted string if really want a line break there. (If you do this -- and don't add any *extra* indentation -- the string will print with no unexpected indentation.)


Top
 Profile Send private message  
 
PostPosted: Sun Aug 07, 2011 4:17 pm 
Offline

Joined: Sat Jan 23, 2010 4:56 pm
Posts: 2081
Forgot to add the other part of the answer: a "carry out" rule can't abort the action. That's why you get the "nothing obvious happens" message; it always moves on to the report phase. Either place your customized print message *in* the report phase, or divert everything in an instead rule.


Top
 Profile Send private message  
 
PostPosted: Sun Aug 07, 2011 4:18 pm 
Online
User avatar

Joined: Sat May 08, 2010 9:25 pm
Posts: 956
Location: The Seattle Massive
The line break rules are specified pretty clearly:
Graham 5:8 wrote:
Inform controls the flow of text being said so that it will read, to the player, in a natural way. There are two principles:

(a) pieces of text ending with full stop, exclamation or question marks will be followed by line breaks (or "new lines", as some computer programming languages would call them); and

(b) pieces of text produced by different rules in Inform will be separated by paragraph breaks.

The effect is that authors can forget about paragraph spacing most of the time...

I agree that it can be awfully freakin' persnickety, and I suspect that at least some of the reason for it is that Inform has always been this way and longtime users are used to it. It'd be helpful, at least, if (a) explicitly stated that a space after a full stop doesn't count.

That said, I think getting rid of (b) would cause far more work than it would remove; making it behave differently is fairly rare and can easily be dealt with by using [run paragraph on]. It does seem as if (a) could be handled better -- line breaks are really kind of crap in most cases -- but I'm sure that this discussion has happened a half-dozen times already.


Top
 Profile Send private message  
 
PostPosted: Sun Aug 07, 2011 5:34 pm 
Offline

Joined: Wed Jul 06, 2011 7:44 pm
Posts: 15
So here's what I just found after some experimentation. This is just the results of some quick test code, and I could easily be missing something. Take everything that follows with a grain of salt:


There are six distinct ways to end a text block. From least likely to produce line feeds to most likely, they are:
Code:
[run paragraph on]
[run paragraph on with special look spacing]
[no line break]
[command clarification break]
[line break]
[paragraph break]

If you don't use any of these instructions explicitly, then ending a text block with a period, exclamation mark, or question mark is equivalent to typing [line break]. Ending a text block with any other character (including a space after a punctuation mark) is the equivalent to typing [no line break].

Also note that the end of a text block can be either a close-quotes, or any bracketed instruction. Hence,
Code:
"Some text.[if x is 5]  Some other text.[end if]"
is two text blocks, not one. (As the original poster discovered.)


The exact behavior of each of these block endings is:
Code:
                         If not the last text       If it is the last text
Instruction:             produced by current rule:  produced by current rule:
------------             -------------------------  ----------------------
[run paragraph on]       No line feed               No line feed
                                                    (next command prompt may
                                                     appear on the same line.)

[run paragraph on        No line Feed               No line feed
 with special                                        (single line feed before
 look spacing]                                       a command prompt.)

[no line break]          No line feed               Single line feed
(or block ends without
punctuation)

[command                 Single line feed           Single line feed
 clarification break]

[line break]             Single line feed           Double line feed
(or block ends with
period, exclamation, etc.)

[paragraph break]        Double line feed           Triple line feed

Oddly, there's no command for "print a double line feed, regardless of whether the current rule produces more text". For this, you need to use two [command clarification break] commands in a row (or a [line break] followed by a [command clarification break]).

Finally, I could find no difference between the behavior of a [conditional paragraph break] and a regular [paragraph break]. (I was hoping the conditional version gave the missing "double line feed no matter what" behavior.) In all likelihood, there is a difference, just not one I was able to find.


maga wrote:
That said, I think getting rid of (b) would cause far more work than it would remove; making it behave differently is fairly rare and can easily be dealt with by using [run paragraph on]. It does seem as if (a) could be handled better -- line breaks are really kind of crap in most cases -- but I'm sure that this discussion has happened a half-dozen times already.

I'm not arguing for getting rid of the present system, just for documenting it better (and maybe reworking a few of its quirkier aspects...)


Top
 Profile Send private message  
 
PostPosted: Sun Aug 07, 2011 10:35 pm 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 2127
Location: Burlington, VT
Thanks very much -- that's very useful.

mucat wrote:
Finally, I could find no difference between the behavior of a [conditional paragraph break] and a regular [paragraph break]. (I was hoping the conditional version gave the missing "double line feed no matter what" behavior.) In all likelihood, there is a difference, just not one I was able to find.


Example 113, "Don Pedro's Revenge," demonstrates the difference -- it uses a conditional paragraph break after reading a command, which prints one blank line after the command. If you substitute a paragraph break or line break, it prints two blank lines instead of one.

Why this happens, I cannot tell you.


Top
 Profile Send private message  
 
PostPosted: Mon Aug 08, 2011 5:39 am 
Offline
User avatar

Joined: Sun Feb 03, 2008 5:55 am
Posts: 298
Thank you all for your input and forbearance.

zarf wrote:
For this case, I always do:

Code:
Carry out pushing the block:
    instead say "First sentence[if the block is that way]. Second, conditional sentence[end if].";

But trying to get sentences in that form gives me a massive headache. And what if one of them ended in a question mark?

Look, my point isn't that there is a bug, or that Inform 7 isn't consistent, it's just that I don't want to have to think about any of this.

In an environment supposedly aimed at writers, I don't want to have to bend my writing around programming conventions.


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group