Routing specific text to a second window.

Is there a smart way to route specific text to a secondary text window? Here is what I am currently doing (I have no idea if this is a dumb thing I’ve hacked together or if there is an easier way, my current understanding of Inform is very beginner level):

Opening a secondary text window using the Flexible Windows extension.

Writing a “Before” rule that could apply to any situation, that uses the Text Capture extension to capture the text that I want to print to the secondary window.

For example, the player wants to examine a book, the description of which is "“A lengthy study on the different species of whale. The keeper has taken margin notes and you dutifully copy the pertinent parts to your journal.” I add in a before rule:

Before examining the book: start capturing text; say "The Baleen, or 'Whalebone' whale is named such due to the presence of Baleen (a form of Keratin bristle-plate that the whale uses to filter for food) in the mouths of this whale species. The Whalebone whale opens its mouth to intake water; then, when it closes its mouth again, it forces the water out through the Baleen plate, which allows the water to pass through while retaining any small fish."; display secondary text; continue the action;

which uses this rule:

To display secondary text: stop capturing text; refresh the bottom window;

and refreshing the bottom window is the Flexible Windows rule:

Rule for refreshing the bottom window: say captured text;

Which works! The player examines the book, and the captured text is routed over to the secondary window (which the player can open and close at will), it’s all great. EXCEPT, the text capture extension has a maximum capture buffer length of 512, which–although it sounds like it might be fine–is too restrictive for what I’m trying to do (essentially preventing me from copying over any text longer than 512 characters). I know you might think here that the easy solution is to break up the chunks of text into smaller captures and route them across one after the other, but it’s more complicated than that because there are times when I would like the text capture to also grab text that is being fed in by other rules that I can’t necessarily control on the fly, that would overflow the buffer.

Is there another way to selectively route text over to the second window – frequently, and at will? (Essentially the functionality that I have but without the buffer restriction).

Googling did throw up an extension called Text Window Input-Output Control by Erik Temple which claims to do this exactly, but I think the extension is broken (Opening a blank project with only the line “Include Text Window Input-Output Control by Erik Temple.” errors out immediately on trying to compile).

Any help is appreciated,

Thanks

Text Window Input-Output Control wouldn’t help with this issue. It is primarily designed to allow you to easily have an input window separate from your main output window. Flexible Windows was completely overhauled after I wrote TWIOC, which is why it won’t work any longer (Inform was also updated, which may be another issue that may prevent my extension from running).

Anyway, the optimal way to do what you want to do probably depends on what final outcome you’re looking for. I don’t see much need for Text Capture, though. I don’t have Inform on this computer to test, but this should do the same work:

[code]Secondary text is text that varies.

Before examining the book:
now secondary text is “The Baleen, or ‘Whalebone’ whale is named such due to the presence of Baleen (a form of Keratin bristle-plate that the whale uses to filter for food) in the mouths of this whale species. The Whalebone whale opens its mouth to intake water; then, when it closes its mouth again, it forces the water out through the Baleen plate, which allows the water to pass through while retaining any small fish.”;
refresh bottom window;
continue the action;

Rule for refreshing the bottom window:
say secondary text;
[/code]

You can concatenate additional text (e.g. output from other rules) into the secondary text variable like so:

now secondary text is "[X][Y]".

In fact, you just have to use the phrase focus (window) before saying something if you want it to be shown in a specific window. You should not forget to focus back to the main window after that.

In fact, Dannii (who updated the extension) explained to me that refreshing the window should only be used to tell what to do when we need to reconstruct the previous state of the window, and that the activity should not be used to manipulate the game world (because it is supposed to be called when the game window is resized, for example).

1 Like

Yes, Natrium729 is correct.

I should probably update the FW docs to explain when it’s best to manually focus, and when it’s best to write refreshing rules.

I disagree with the practical advice you seem guys seem to be implying. You don’t want the window to refresh as a blank (at least I don’t), so you essentially always need a refresh rule. It’s a good idea to assign a global variable, as here, to contain the desired state of the window. Whether to use the manual focus rule or a refresh rule for updating is mostly a matter of style.

I’d say it depends on whether you want a secondary scrolling log type window, in which case focus but don’t have a refreshing rule, or a window where each update replaces the previous, which should use a refreshing rule.

That’s true. I interpret this use case as the latter, since it seems that the window is updating with the description of examined items. But the OP hasn’t really specified the desired behavior.