Login
Remember
IF Answers
Ask a Question

# 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?

- inform7

## 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

## Related questions

- What are best practices for modifying extensions in Inform 7?
- What's the best way to test whether or not scoring is being used? (Inform 7)
- Is there an easy way to port Inform 6 code (unfinished game) into Inform 7 to continue development?
- How does punctuation work in Inform 7 code?
- How to make relations and states in Inform 7

...