Your regular programming will resume shortly, but first a short interlude on some of the technicalities and peculiarities of Inform 7. Inform’s IDE has some handy shortcuts (on Windows at least): F5 will compile and launch your story, while F9 will compile and replay the last game: Excellent for debugging. F7 on the other hand will just compile and rebuild the built-in index tab which is a great resource while developing. It’s a good habit to compile often as it can be daunting to debug larger code changes even if the compiler is good at pointing out what went wrong.
As we’ve seen earlier, source code in Inform is written in natural language, but that doesn’t mean it actually understands English. Just like any other programming language Inform has a rather strict syntax to follow, it’s just that Inform’s syntax is easy to read. Anything Inform should recognize as text should be written inside double-quotes, and single quotes inside a text is converted to double-quotes when bordering whitespace. Anything written inside square brackets in a text is considered to be substitutions, while square brackets elsewhere is considered to be comments.
Unlike many other programming languages (such as TADS, other C-like derivations, and even Inform 6), Inform 7 is limited to only one source file. In lieu of dividing the source into several files, I7 uses five ‘header’ types for organizing your code into modules. In decreasing order of magnitude, these headers are Volume – Book – Part – Chapter – Section, or in a easy-to-remember mnemonic: Very Bad People Choose Satan. Exactly how to divide your code with these headings is largely up to each author, but a template project setup based on my personal preferences is included herein. My personal preference is to use ‘chapter’ as the main holder of sourcecode, divided into sections as needed and using ‘volume/book/part’ for hierarchical organization.
Structuring the source code with these headers has three main effects, the first of which should be pretty obvious. By building a hierarchy of headings it’s easy to place related content near each other, using the interface’s overview to jump around. The second effect is less obvious, and related to a feature we briefly covered before: the ‘Use unabbreviated object names’ phrase. When this use option is not enabled we’re allowed to refer to objects in our source by abbreviated names, such as referencing the ‘kitchen table’ by just ‘table’. If an abbreviated name could be taken to refer to multiple objects (for instance a ‘coffee table’ as well), Inform uses the hierarchy of headings to select the closest match. My personal preference is using unabbreviated object names, which avoids mishaps when re-arranging code. Lastly, Inform also uses these header to tell you where a compile error was detected.
To help debugging your story Inform supplies a variety of testing commands as well as the option of easily creating test cases and special actions that are removed from the final release. The default testing actions included in Inform is:
- ACTIONS on/off: Toggles the printing of exactly which actions are processed, as well as printing the name of any failed rules without swamping the output.
- RULES on/off: Toggles the printing of all rules being consulted for a very detailed and verbose feedback only recommended for ferreting out tricky bugs.
- SHOWME object: Lists out all of the properties for the given object as they appear at the current runtime state.
- PURLOIN object: Moves the object from anywhere in the world model into the player’s inventory.
- GONEAR object: Moved the player as close as possible to the given object anywhere in the world model.
- SCOPE: Lists out all of the objects that are currently in scope for the player to interact with.
- RELATIONS: Lists out all the various kinds of relations that are in use in the game.
- SHOW RELATION relationship: Lists out the details of a specific relations, as detailed in 13.7 of ‘Writing with Inform’.
This extension also provides a ‘debug examine’ action (shortened to ‘DEX‘) to provide detailed information on the kinds most relevant to AIF: garments, body parts and persons. It’s also possible to write both test cases and special commands only available during testing, which can be used to artificially set story progression variables. Test cases can be written by the phrase ‘TEST testname WITH “actions / separated / by / slashes”.’, allowing you to write ‘TEST testname’ during play to execute the given actions in order. To create commands only available for testing you can mark one of the source headers as ‘Not For Release’, which is described in chapter 2.9 of ‘Writing with Inform’.
It’s very important to take the time to explore your world and experience it as a player would. One of the harder parts to test is when connections between room differs from the room description. To help test this you could use the included extension ‘Directionality’ which auto-generates a description of the available exits in a room.
Before moving on to some more programming in Inform, I would recommend exploring various tabs in the IDE, especially ‘Index’ which gives a helpful overview of your story world.