How do I display text in a box (like Photopia)?

I’m making a short little text adventure, and I finished Photopia today. Photopia has these little boxes with text in them to transition from places, and I wanted to know how I could do that in Inform 7 if it’s possible.

See chapter 5.12, “Displaying quotations”, in the I7 manual.

1 Like

The phrase you’re looking for is probably display the boxed quotation, which can be used along the lines of display the boxed quotation "The unexamined life is not worth living.[line break] -Socrates". I am not in front of my laptop right now and cannot find the exact reference, but searching the documentation in the Inform IDE for that phrase should turn up an appropriate part of Writing with Inform.

I myself am not a big fan of the way that this works under Glulx, however: the constraints of the Glulx VM make it impossible to overwrite text that’s already been written to the screen, which is a good move in many ways from a technical perspective but makes it impossible to display a boxed quotation in the style of, say, Infocom’s Trinity. Instead, the status line is expanded to display the quotation, which is less pleasing than the Trinity-style boxed quotes. Since the player’s eye is usually focused on the bottom of the screen and the status bar is at the top, it’s also less noticeable.

One thing you might consider doing instead is something along the lines of: before you print a quotation, first you print several lines of empty space; then you print the quotation to the screen, normally, using say phrases, and indented; then you print more empty space. If you’re thinking “OK, and why don’t I clear the screen and/or wait for a keyless before doing that?,” look at the Basic Screen Effects by Emily Short extension.


This is what I got. It just displays at the very top, and it doesn’t even include the mentioned line break.

EDIT: I forgot to set my game to Z-Machine. Oops!

1 Like

It did work, but I can’t get it to work right with the pause.

when play begins:
	display the boxed quotation
		"Boxed quotation.[line break] -Some Fashionable Guy";
	wait for any key;
	clear the screen.

It results in a blank screen, and when I press the key, it then shows the boxed quotation but inside the game. How do I fix this?

WI 5.12:

Rather than being shown immediately - and thus, probably, scrolling away before it can be seen - the display is held back until the next command prompt is shown to the player.

But if you read its docs, Basic Screen Effects has us covered with a show the current quotation phrase. This is nearly the same as an example from BSE:

when play begins:
display the boxed quotation
"Boxed quotation.
-Some Fashionable Guy";
show the current quotation;
pause the game;
clear the screen.

Note that adaptive text doesn’t work with display boxed quotation: this is a rare (unique?) case where Inform will literally output [line break] and not change that into a line break. Hence the multi-line text I used above.

You’d have a lot more options and control (and a lot more work) if you used Flexible Windows by Jon Ingold. There isn’t a boxed quotation feature, but there is a means of putting characters in precisely defined places that would let you implement one. It would also restrict you to compiling to Glulx, not Z-Code.


Example (I had most of this lying around):

"boxed quote"

Include Alternative Startup Rules by Dannii Willis.
Include Basic Screen Effects by Emily Short.
Include Flexible Windows by Jon Ingold.
Include Text Loops by Zed Lopez.

The initial whitespace rule does nothing.

Title quote is always
"And the wabe is the grass-plot round,[line break]
a sun-dial, I suppose?' said Alice,[line break]
surprised at her own ingenuity.[line break]
[line break]
'Of course it is. It[']s called wabe,[line break]
you know, because it goes a long way,[line break]
before it, and a long way behind it.'".

To my-set (win - a text grid g-window) cursor to row (row - a number) column (col - a number):   
(- glk_window_move_cursor({win}.(+ ref number +), {col} - 1, {row} - 1); -).

To solicit pressing any key:
    say "Press a key to continue > ";
    wait for any key;

When play begins:
  let len be 0;
  repeat for line in lines of title quote begin;
    if number of characters in line > len, now len is number of characters in line;
  end repeat;
  close the status window;
  now the measurement of the status window is number of lines in title quote + 2;
  open status window;
  focus status window;
  let prefix be (the width of the status window - len) / 2;
  repeat for line in lines of title quote with index i begin;
    my-set status window cursor to row i + 1 column prefix;
    say line;
  end repeat;
  focus the main window;
  solicit pressing any key;
  now the measurement of the status window is 1;
  clear the screen;

Lab is a room.
1 Like

Also, though it’s from 2009 and thus likely written for 5Z71, Glulx Boxed Quotation by Eliuk Blau is almost entirely Inform 6 and seems to still work. But it’s based on display the boxed quotation and thus needs some literal string and can’t handle adaptive text.

1 Like

I haven’t tried the extension, but couldn’t you just pass the substituted form of the string containing adaptive text to the relevant routines in the extension?

Nope, it’s a weird special case that won’t compile without a text literal.

 >--> I attempted to compile 'display the boxed quotation t' (source text, line 6),
    but the text 'a temporary named value' supplied to be a boxed quotation
    wasn't a constant piece of text in double-quotes. I'm afraid that's the
    only sort of text allowed here.

This doesn’t have to do with the extension; it’s an I7 issue. In fact, the extension doesn’t have to do with anything anymore, and I was confused in the moment to think it had any relevance in the modern world. It apparently was written at a time when display boxed quotation only worked when compiling to zcode with I7 out of the box.

1 Like