I’m porting an old text adventure game that uses 5-character prefixes to do tokenization; i.e. it stores its dictionary as e.g. ‘ABC’ and ‘FOOBA’, which will allow the player to type either ‘ABC’, ‘FOOBA’, ‘FOOBAR’, or ‘FOOBARABAZ’ etc. (but not ‘ABCD’). This is important because the game is in Hungarian, an agglutinative language (https://en.wikipedia.org/wiki/Agglutinative_language).
How would I do that in Inform 6? I am currently using the stock tokeniser from the Inform 6 standard library, and it’s completely opaque to me so I’m hoping someone has a solution that I can apply without diving deep into the implementation details of Tokenise.
If you’re compiling to Glulx, you can use the DICT_WORD_SIZE setting to set the number of characters in dictionary words, like so
inform6 $DICT_WORD_SIZE=5 game.inf
If you set this, and the game has a dictionary word ‘fooba’, then input of ‘foobarbaz’ will match ‘fooba’. If you’re compiling to Z-code, dictionary words are always 6 characters (strictly speaking, 6 Z-characters, but that gets complicated, and you didn’t ask about that).
Is there a way to set DICT_WORD_SIZE from the code itself, so that it doesn’t depend on the way ‘inform6’ is invoked? I can’t just set it as a constant, because that gives me
line 4: Error: Expected new constant name but found DICT_WORD_SIZE
You can put compiler options at the top of the I6 source file, like so:
No spaces, blank lines, or other comments before the “%!” line.