Is it common for IF authors to use a standard library they have accumulated from their own and other's source code?

Hello @BubbaBobba ! Welcome to the Intfiction forums! :smiley:

What I’ve found to be more helpful than accumulating code or creating start templates, is heavily notating the code used in your projects. You may want to do something in a later project similar to something you did before. Naturally, you will think of times you did something similar, and will go back to take a look at how you accomplished that. This beats searching the manual or forums to rediscovery something you already solved. No sense in recreating the wheel each time.

However, being able to, months or years later, even find that relevant piece of code amongst the whole source, let alone interpret it once you do find it, is often easier said than done.

This is why I often signpost where certain code segments start and end, what they do, what variables are involved, how they work (if I understand that), and sometimes even SEO tags to help me find it later if I think it’s valuable enough. I want to be able to bring up the source on any of my projects, search with “find on page” and immediately find what I’m looking for. This is the same reason I don’t delete old projects, even if I decide the premise isn’t worth pursuing any longer; I’ll scavenge from my own code for years as long as I took the time to make it accessible and intelligible.

If you take the time to do this, then everything you ever wrote becomes a searchable reference for future work. This is what I’ve found to be most helpful.

6 Likes

Hello BubbaErik!

When I first started working with Inform 7, I would look at the source code for Bronze constantly for inspiration and for ideas about what might be “best practice” when using the language. My own source code (unlike my desk, and my home) tends to be quite organised!

To date I have made four released and two unreleased I7 games. Nowadays when I start a game I begin by copying over large chunks of code from my previous games. Over time I’ve developed ways of handling things like NPC descriptions (and the way they’re described in rooms) that are very flexible and work just as well in one game as another. Other pieces of code I reuse include exactly the things you’ve listed, smells, sounds, staircases, floors, windows, distant objects (things that are too far away to touch) and things that exist in one location but which can be seen from another. I also reuse code for actions like throwing things and emptying containers. Lots of clever forum members including Matt Weiner, OtisTDog and the very modest Zed Lopez have posted useful bits of I7 code on the forum which have found their way into my recent games, and it’s always worth asking if you can’t work something out. Nobody will mind and somebody will enjoy the challenge.

In terms of extensions, I regularly use Locksmith and Basic Screen Effects by Emily Short, Scheduled Activities by John Clemens and Epistemology by Eric Eve. Several of my games include Eric Eve’s Conversational Responses and one uses his entire conversational package.

My games are quite self-similar. They tend to be focused on object-manipulation puzzles (what have been called ‘medium-sized dry goods’) because that’s the way my mind works. I’m also quite NPC focused, so I have a fair bit of code for handling NPC interactions which can be adapted from one game to another. If I were to try to write something in the style of, say, Arthur DiBianca, Mike Spivey or Andrew Schultz - not that I’d ever try! - a lot of my reusable code would probably be irrelevant, because those authors write very different styles of game. Inform 7 is a very versatile language, and even to an experienced author, other people’s games can seem like magic!

8 Likes

This is how I’ve been approaching my tutorial game I’ve been making for myself. I make a comment before each piece of code briefly describing what it is trying to do.

The other thing I’ve also found interesting is that often with a clever description of what a player is doing after that complete an action it can circumvent the need to write any code at all that modifies the game world. The more I look at other games I have noticed that often times clever writing is a more elegant solution than clever coding.

I’m actually really surprised at how many games have their source code available now that I started actively searching. It’s fascinating to see how authors build their game worlds.

5 Likes

No matter if you’re writing games, operating systems, embedded stuff, industrial controls, and so on; you’ll come across similar problems again and again. Therefore it’s a good idea to keep a personal library.

3 Likes

I am currently working through Eric Eve’s TADS 3 Tour Guide. It is a wonderful survey of TADS capabilities (and about 400 pages).

I have been working through it for weeks. The learning is an adventure, almost like playing a game of IF. As I progress, I am annotating/commenting the source code. Ensuring that things work as intended is a great learning process.

PS. I have been through the similar text using Eve’s Adv3Lite library. I have found that I much prefer the standard TADS 3 Adv3 library.

Michael Roberts and Eric Eve are incredible programmers!!!

4 Likes

I’m not a seasoned IF author, but already I’ve built up a small pool of reusable code I use between my various works-in-progress.

Note that I code in TADS, which has the modify and replace keywords. This allows authors to patch the built-in library. Most of my reusable code falls into this category.

Some of my code is what might be called “boilerplate” that I’ll need in almost any game. For example, in TADS you need to supply a versionInfo object which details the game’s metadata (title, header, etc.) and author information. While the former changes game to game, the latter doesn’t, so I might as well reuse what I can there.

Lastly, I’ve developed utility classes I’ve found so useful that I can’t imagine starting a game without them in my tool belt.

One things about this approach, though: If I add a feature to my mini-library, or even fix a bug in it, I won’t copy that code into a released game unless it fixes a bug specific to that game. In other words, when I release a game, it’s code is “frozen.” (Or perhaps “ice-slushy,” since I’m still open to fixing problems reported later.)

This is a sanity-preserving measure. While copying improved code back into a released game sounds good on the surface, that’s also how new bugs are introduced.


A word on coding philosophy: The bulk of software coding best-practices handed down the ages revolves around continuous development and maintenance. I’ve come to believe that in writing an IF game one has to be more pragmatic and use more short-term thinking.

Most IF games are not strenuously maintained after they’re released. Unlike desktop software (where version numbers can run into hundreds, and be maintained for years) or web sites (which are continuously updated, often several times per day), a typical IF game may have less than five releases.

So while I do maintain a small library of reusable code, the bar for adding code to it goes like this: “Am I certain I’ll use this in another game?” and “Does this help me build games faster?”

The first question explains itself. The second is that pragmatism I mentioned. A lot of my coding time is spent adding new rooms, adding new items, writing descriptions, dealing with PC travel…general world-layout mechanics.

So, if I can find little short-cuts to speed up that part of the process, that gives me more time to work on the custom mechanics and puzzles of my current game, which are its meat and what makes it unique.

7 Likes

Pertinent to this topic: I was going through various old inform projects and I came across a very early (and adorable) attempt at creating a new game template. I had completely forgotten about it (and had obviously abandoned the effort early on), but I though I’d share it here for anyone curious.

Source Code

[Settings]

[Name and Author]

“Template” by Unknown

[/Name and Author]

[/Settings]

[Player Start]

[Player Character Starting Location]

[…The Player is in…] [Starting location]

[/Player Character Starting Location]


[Carrying Capacity]

[…The carrying capacity of the player is…] [max carrying capacity]

[/Carrying Capacity]


[Starting Inventory & Clothes]

[…The player carries…] [describe item]

[…The player wears…] [describe clothes]

[/Starting Inventory & Clothes]

[/Player Start]

[Title of First Act]

[…Title…]

[/Title of First Act]

[Rooms & Regions]

[Rooms]


	[Room - Room1]

[…The Room1 is a room. The description of Room1 is…] [describe room]

	[/Room - Room1]
	

	[Room - Room2]

[…The Room2 is a room. The description of Room2 is…] [describe room]

	[/Room - Room2]
	
	
[/Rooms]


[Regions]


	[Region - Region1]

[…The Region1 is a region. Room1 and Room2 are in Region1.]

	[/Region - Region1]
	

[/Regions]

[/Rooms & Regions]

[Scenery, Objects, & Doors]

[Scenery]


	[Scenery - Scenery1]

[…Scenery1 is scenery in Room1. The description of Scenery1 is…] [describe scenery]

	[/Scenery - Scenery1
	

	[Scenery - Scenery2]

[…Scenery2 is scenery in Room2. The description of Scenery2 is…] [describe scenery]

	[/Scenery - Scenery2]
	

[/Scenery]


[Objects]


	[Object - Object1]

[…Object1 is in Room1. The description of Object1 is…] [describe object]

	[/Object - Object1]
	

	[Object - Object2]

[…Object2 is in Room2. The description of Object2 is…] [describe object]

	[/Object - Object2]
	

[/Objects]


[Doors]


	[Door - Door1]

[…Door1 is a door…]

	[/Door - Door1]
	

[/Doors]

[/Scenery, Objects, & Doors]

[Backdrops]

[Backdrop - Backdrop1]

[…Backdrop1 is a backdrop. It is in Region1. The description of Backdrop1 is…] [describe backdrop]

[/Backdrop - Backdrop1]

[/Backdrops]

[Actions]

[Action - Action1]

[…After going to Room2 from Room1: say “…1”; continue the action.]

[/Action - Action1]


[Action - Action2]

[…After going to Room1 from Room2: say “…2”; continue the action.]

[/Action - Action2]

[/Actions]

1 Like

I find that the Inform Recipe book has weird holes most of the time. It gives one example that’s way too simple, and then another example that’s way too complicated. It often seems to me to be missing a few “just a few regular usage” examples.

3 Likes

I definitely use my own previous source code and the source code of other people as my best reference. My own work “The Land of Breakfast and Lunch” was my learning project and has a bunch of great “IF Template” type stuff:

Another amazing work I drew on heavily was @aaronius’ massive IF work Blue Lacuna:

Blue Lacuna has some incredible “quality of life” upgrades for people, including detecting if you’re probably someone used to text games and making the puzzles easier or harder dynamically(!!!?!) but also just adding some common things neophytes might type. He also has some incredible sets of random content that’s responsive to time of day, the tides(!!) and other factors. It’s a lot of source code but since he literally wrote the Inform 7 book, you can find a wealth of good examples.

People are mentioning Bronze, and now that I see the source code I definitely wish I’d know about it before!

3 Likes

The Inform 7 Documentation and Resources sticky post has a selection of games with published source code. And, of course, there’s plenty more I7 code to consult in the Friends of I7 extensions repo.

I’ve got the above and the examples from the docs and more all under one directory; a script to search for text in them is one of my go-to’s to check syntax.

1 Like

Sounds like a candidate for a thread title to me.

1 Like

Wow the source code is an absolute monster. I began playing Blue Lacuna the other night and was way too tired to really start something new and got a bit lost in the setup process. The game had me adjusting nouns etc to italics or bold etc but I wasn’t able to see them in different colours which seemed like might be useful. Which interpreter would be preferable for this game?

I recently started using Lectrote in favour of Frotz and Splatterlight as it seems to have the best compatibility with different formats along with platform.

Unfortunately the inform 7 book he wrote is unavailable in my region on Amazon. Has he released this as an E-Book by any chance?

4 Likes

Bitching about the Inform 7 docs? I think it’s been done.

1 Like

I do not remember what I used! I actually played very little of it myself, I experienced it almost entirely via reading the entire source code. Good question for @aaronius who often comes around here.

Yeah the lack of availability is a bummer I’m sure @aaronius is aware of. It’s far better than any other resource for the game and explains many of the core concepts in a way nothing else does, even though it’s supposedly out of date. Unfortunately @aaronius doesn’t own the rights to the books. I bought an expensive used copy myself. At the time eBooks were available but I see it’s utterly gone now. Can’t anything be done, @aaronius?

2 Likes

It’s been a few years since I fired up Blue Lacuna myself, I have to admit. Checking it out just now on my Mac, I see that Spatterlight displays the colored text, but Lectrote does not (don’t have easy access to Windows just now). The game was definitely designed to be playable without it, though, since color support in interpreters was (and is) inconsistent. I would personally just set all the styles to bold or whichever of the alternates is most distinct in the interpreter you’re using.

Re: the Inform 7 book: it’s been a source of frustration to me for years how bad the publisher has been at keeping it available. The good news is that I finally got the rights back to the text of the book: the bad news is that I need to re-do the layout and cover design to rerelease it (since the particular presentation of the Cengage release is part of their copyright). I also would really like to update it for modern Inform, which shouldn’t be too awful but will need to be done with some care not to break the incremental steps in building the example game and so on. Also, a lot of the references in the text (and frankly, in the example game itself) are a little dated now, and could stand being refreshed.

So in short, getting a new version of the book out is going to require an amount of work between “some” and “a lot” and I just haven’t had the spare bandwidth to focus on it yet. I do hear the interest from folks, though, and would really love to get a new version out there at some point-- just can’t promise when!

9 Likes

Well, negativity’s easy. I was hoping for a more positive thing than that. Something more like, “there’s a real need for a bodypart aware clothing system for I7*. (How hard can that be?)” LOL. :laughing:

*this is just me grabbing an idea out of the air, for the sake of an example.

Generally, I think that the bits that authors need help with are coding NPCs. I know: NPCs are hard – but people wanting to tell a story don’t care whether the bits they need to do are easy or hard, they want to do the bits they want to do. And if they want to tell stories, then they need to code characters. That’s just how it is. I think that if we want to see IF move on and do new things then we need to help new authors code NPCs. Whether that’s coding libraries like Threaded Conversation or specialist apps that help writers write dialogue and then spit out Inform/TADS/Dialog code, I dunno.

But a start would be “hey, here are some more Cookbook examples”.

2 Likes

I was fortunate, I was able to purchase both the hard copy and the Kindle version while they were available on Amazon.

Aaron has talked about republishing in some form in the future. Maybe it will be updated for the pending Inform 7 update. (Maybe at Narrascope 2022?) I have zero knowledge just supposition.

3 Likes

Barnes & Noble says Creating Interactive Fiction is available for the Nook and CEngage says you can still order the physical Creating Interactive Fiction book. If anyone tries ordering 'em, let us know how it goes…

4 Likes

This is why I love this community and forum in particular! So cool that the community is so tight knit. I just fired it up on splatterlight and it was in colour so I might give it a whirl there instead.

Personally I would be very interested in an updated version if you got around to doing it. I nearly bought the nook book version but held off as I had read that it’s better to use the version of inform that it was based on.

I have a lot on my plate with work and personal life as it is atm so I’m only at the point of being able to approach learning I7 in my limited spare time.

Thanks for the reply though, much appreciated and I look forward to hearing of any developments in regards to your textbook.

Cheers!

4 Likes

I would disagree with elements of this, certainly from the view of more retro text adventure development and authoring systems where you’re having to implement things on a lot more of a case-by-case basis than in modern IF systems like Inform.

Back in the day it was common to not only reuse sections of code that you’d utilised in your own adventures but also “borrow” sections of other author’s code. (Even now I’m always loading up old games that I’ve written to nick bits of code from them, rather than sit down and work out how to reimplement that same thing again.)

We also used to share our GAC, Quill, and PAW routines in tutorials in magazines and fanzines back in the day… and there were whole adventure writing books and magazine articles… so, yeah, I guess you could say those would count as “publicly accessible libraries”. Just a lot more “offline” than ones these days.

In fact, it was tutorials like Ken Reed’s seminal Practical Computing article (Adventure II by Ken Reed) that many authors used as a basis to develop their own “IF” systems. Without sharing code like this (Ken Reed work itself was built upon an earlier article by Scott Adams) we wouldn’t have had half the 1980s adventuring systems that we did.

7 Likes