I’m trying to build an extension for printing text in real time. Currently my “printer” prints text at a rate of 2000 characters per minute. When it starts printing, it pauses the game (i’m building a real time game), then unpause it when it has finished printing text.
When the system process the “To tell/type (T - sayable value)” phrase, T is registered in a table. Then, every tick, the system prints a few characters of T.
T is registered in my table as a text if it is a text otherwise it is registered as indexed text. This way, i’m able to register phrases in the table (as i7 texts can be i6 routines) : if the “bold”, “italic” and “roman” types are defined by a routine rather than by an i6 inclusion, the system is able to reproduce the text’s style when typing it.
But I haven’t succeeded in reproducing the paragraph control system. I think the main reason is that paragraph controls doesn’t entirely rely on routines : i wish “say__p = 1” was wrapped into a routine.
That’s why i’m looking for another solution :
-obviously i can’t store style informations into indexed texts.
-From Gluxl for Dunces : However, setting text styles in file streams will probably be ignored, although not necessarily. While the setting of text styles in memory streams will always be ignored (see File References below).
I’m not real sure, but I think you can override I7’s bold/italic/roman to-say phrases with your own that could instead output an illegal or reserved character which will land in the indexed text. Then your printer can turn the illegal character back into the style. I think you can also override line break and similar phrases similarly.
Did that answer your question?
yes, i think so. I guess there is no way to “truly” store styled text . You can either store style instructions into routines or into special characters. The latter seems to be the best solution. But can I use unicode characters ? And what are illegal characters ? negative values ?
I think i will try to create a new relation between phrases and indexed texts (P is symbolized by T), and wrap the in-line style instructions into routines. This way, i’ll be able to trigger phrases in the middle of indexed texts, which could turn to be useful if one wants to modify the behavior of the printer.
In the extension Output Filtering, I just used curly braces and an angle bracket. They don’t tend to occur in a game’s prose.
[code]
Chapter - I6 helper routines for Output Filtering
To say bold type: (- bold_on(); -).
To say italic type: (- italic_on(); -).
To say roman type: (- roman_on(); -).
To say blank line: say “[bracket]BLANK LINE[close bracket]”.
To say the/-- filtered (itext - indexed text): (- SayGameResponse(({itext})); -).
Include (-
[ bold_on;
if (capture_active > 0) print “{”;
else style bold;
];
[ italic_on;
if (capture_active > 0) print “<”;
else style underline;
];
[ roman_on;
if (capture_active > 0) print “}”;
else style roman;
];
[ SayGameResponse indt ch i dsize;
if ((indt==0) || (BlkType(indt) ~= INDEXED_TEXT_TY)) return;
dsize = BlkValueExtent(indt);
for (i=0:i<dsize:i++) {
ch = BlkValueRead(indt, i);
switch (ch)
{
0: return;
255: return;
‘{’: style bold; continue;
‘<’: style underline; continue;
‘}’: style roman; continue;
#ifdef TARGET_ZCODE;
10: continue;
#endif;
}
#ifdef DEBUG_OUTPUT_FILTERING;
switch (ch) { ! then print ZSCII values instead
32: print " ";
10: print “^”;
default: print ch, " ";
}
#ifnot;
#ifdef IT_Storage_Glulx_Unicode;
glk_put_char_uni(ch);
#ifnot; ! IT_Storage_Glulx_Unicode
print (char) ch;
#endif;
#endif;
}
];
-).[/code]