Best practices for Inform 7 code organization and style?

0 votes
185 views
asked Apr 18 in Authoring by almightyjanitor (3 points)

When my projects get anything larger than a few rooms, the code becomes an unorganized mess. I have to ctrl-f around to find anything. What do you guys do to keep your code clean and maintainable?

1 Answer

0 votes
answered Apr 18 by bg (692 points)
edited Apr 18 by bg

Here are a few things you can do for organization. No doubt others will have more suggestions.

There are five levels of headings available--"volume", "book", "part", "chapter" and "section"-- so you can use them as liberally as you like. That way you can click to the section you want from the Contents pane instead of using control F. (For info on headings, see ยง2.5 in Writing with Inform.)

If you want to be able to move sections around easily (e.g. if you decide at some point to organize a bunch of sections chronologically instead of geographically/alphabetically/whatever) you don't need to give the headings numbers. You can just give them titles (for example, "Book - New Actions" instead of "Book 1 - New Actions").

When there is more than one section where a code chunk might reasonably belong, I try to be consistent in where I put things. For instance, deciding to always put new actions under the "new actions" heading instead of in a room where that action is used.

Studying the source of Emily Short's games is probably a good place to start for organization: http://ifdb.tads.org/search?searchfor=tag%3AI7+source+available+author%3Aemily+short&searchgo=Search+Games

This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...