I'm writing a text adventure game ("interactive fiction", if you prefer) called Hex, and I'm doing it using Inform6. I know that Inform7 has been out for a very long time now, but I'm not sure I like the approach it takes, and I think Inform6 better fits the way my programmer's brain works.
Before getting going with the game itself, there were a few things I wanted to see whether I could make work (since, without them, some of my game ideas either wouldn't work, or would need to be implemented awkwardly).
I wanted the player to start in a room which has six coloured doors (the directions of which are not specified) and:
The idea is that the player has a free choice of which door to open and go through, but once that choice is made, s/he can't decide to open another one instead (and, if the player returns to the room after exploring whatever is on the other side of the door, the other doors remain locked and unusable, unless the player has managed to find any key/s in the meantime).
Here's what I came up with. Given that I've been using Inform6 for a total of two days so far, I think I'm quite pleased with that. (The rest of the things below were worked out after the first two days…)
Inform6 expects you to define rooms such that each one explicitly states where you can get to and in which direction.
This means that if you have a hallway, which leads north to a kitchen, you have to make sure the kitchen also leads south back to the hallway (unless it's supposed to be one-way, which is entirely possible, and sometimes necessary, but not the most common arrangement). This is, in my opinion, a bit tedious (and potentially error-prone, especially if you later decide that a room leads east off a corridor instead of west, for example, but forget to ensure that the corridor is now west from the room).
The Inform6 Designer's Manual gives some useful clues (although not a fully-worked example) about how to define a link between two rooms such that the reverse link puts itself automatically into place. I think that should be standard for room definitions.
The clues are on page 440, in the answer to challenge number 13 (which is on page 114).
Here is how to actually implement it.
In Inform6, doors are inherently one-way things:
So, assuming you want to have a house with a door which you can enter from the garden (and arrive in the hallway), but which you can also use to exit the house from the hallway to the garden, you are expected to create two doors, one leading in each direction.
I think this is (a) ugly and (b) error-prone (you might change the direction of one door and forget to change the other one).
Exercises 3 and 4 of the Inform6 Designer's Manual (challenges on page 90, solutions on page 436-7), plus the comments at the end of the "doors" chapter (13, on pages 122-124) give some clues about how you can create more advanced doors, but the best example I found so far is the toilet door on page 138 of the Inform Beginner's Guide, which shows how to create a door which looks different from each side, and which leads to different places in each direction (as you might well expect of a door - if you go through one way, you leave room A and arrive in room B; so if you go through the other way, you expect to leave room B and arrive in room A).
So, using all the above, I created some doors which automatically work in both directions with correspondingly different (if you want) descriptions on either side.
Sometimes, you don't want a thing, or a place, always to have the same name or description.
For example, I'm considering including a dyslexic dragon into Hex, so the sign to the "Dragon's Den" might well say "Gandor's End", "Grand Nodes" or "End drags on", and change from time to time as you look at it.
Similarly, I think the technique could be useful for the names / descriptions of rooms in a maze, so that (a) you don't have to create many actual rooms, and (b) the maze is non-deterministic and therefore unmappable.
The random() function in Inform6 allows you either to generate a random number, or to select one of a number of "values" from a list. These "values" can be numbers, strings, objects - anything representable in Inform6 language.
So, here's how to create some random names and descriptions for objects.
(I'm rather particularly pleased with this one.)
I wanted the Hex player to have to earn (or find) money, and use it to buy things in the game.
I also wanted it to be "realistic" money with different denominations, rather than just a simplistic "you have 235 credits" way of doing things.
Two denominations would be just like Pounds and Pence, or Dollars and Cents, or Euros and Cents, but I wanted the game to be a bit different, with three denominations (perhaps because I grew up in Britain with Pounds, Shillings and Pence).
So, here are the new functions I came up with to achieve that. Any location which sells stuff is expected to have a shop attribute (this means you'll get told the price of things which are for sale when you examine them, but outside the shop you just get the description, for the same items), and any item which can be bought needs to have a price property. You can then use the buy verb to (try to) buy the item. It will tell you if you don't have enough money, or if you do, it'll pay for it and also get change if required.
The money itself simply costs of standard items in your inventory.
Go up
Return to main index.