you’ve been following along with this tutorial for the last three
months then you should have quite a bit of text written by now.
This month we will be taking a brief look at Inform 7 and how to use it
to put all that text together and make a game out of it.
That’s right, it’s programming time. Before you run
off screaming into the night let me offer a few words of
encouragement. While it is probably not going to be as easy as
you would hope, it is also not as hard as you might fear.
We’ll be keeping it simple and taking a few shortcuts that should
make the process fairly painless.
Before we get started I should mention that I have only used the Windows version of the program. It is also available for Mac and Linux. There are a few differences between the three programs so I can’t guarantee that everything will work exactly the same for the others. However, most of the difference are minor and have to do with the interface rather than the program itself so this really shouldn’t be an issue.
If you haven’t downloaded the program yet you can do so for free at the Inform website at http://www.inform-fiction.org/I7/Inform%207.html.
One of the things I really like about Inform 7 (I’m just going to say ‘Inform’ from now on) is the program interface itself. When you run the program you are presented with a screen offering three options. Basically, you can start a new project, open an existing project, or reopen the last project you were working on. Obviously, if this is the first time you have run the program then there are no existing projects so your options at this point are limited to one. See how easy that is?
When you click on start a new project a screen will open and ask you for three things. The directory where you want to put the project, the title, and the author (that’s you by the way). Enter the information it requests and click start and your new project will open. The interface itself looks a little like the two facing pages of an open book. On the left is your title and name (and a depressingly large amount of blank space). This is your source text and is where you will actually be writing the game. On the right should be the documentation screen. The nice thing about this program is that you can change both of the ‘pages’ to anything you want. Above each half of the page are tabs allowing you to change what information is displayed on that half. Personally, I have always just left my source on the left and changed the right to whatever else I need at the moment but you can do it any way you want.
In addition to the source and documentation screens there are also several others to choose from. I’ll mention just three of them here. They are ‘errors’, ‘game’, and ‘index’. At the top left of the screen is a button that says “Go.” Every time you click this button the program will try to compile your game, reading all the text you’ve written as well as any extensions that you have included and will try to put it all together into a game. If it hits something it doesn’t understand the errors screen will open automatically and attempt to explain what the problem is. You should become used to seeing this screen pop up. Even when the problem is something very small and easy to fix it still gets its own error message so you will see it a lot.
Once all the errors are taken care of the game screen will open, showing the starting location of the game just like you were loading it up in another program. The nice thing here is that you don’t have to load it up in another program. It’s right there on the same screen. If you notice a spelling error or something that you want to fix then your source text is still displayed over on the left (or right if you’ve flipped it) and you can change it without having to close and open different windows. You can play through the whole game on this screen, making corrections as you go.
The index tab has a lot of information and I won’t go into it all here as you wouldn’t understand what most of it meant at the moment (don’t worry, you will). There are sub tabs breaking the information down into categories and as you go through your project you will find the information here very helpful. The information ranges from general things built into the main program, right down to a list of every room, object, and person you have created in your game. There are also other tabs to choose from but I’ll let you find those yourself or read about them in the manual.
Are you ready to get to it? Are you ready to take all that text you’ve been writing and make a game out of it? Let’s start at the beginning and make a room. For our little test game here let’s start with an office. Here is how you program a room in Inform.
The Office is a room.
No, I’m not shitting you, that’s it. That creates a room called ‘Office’ and even more than that, it actually makes a complete, working game. The one and only requirement that Inform has is that a game must have at least one location so you can write those five words and the hit the go button and Inform will compile the game and put the player in the office. (Note that by default the starting location of the player, and thus the first room of the game, is the first location created but this can be changed if you wish). Of course it’s a pretty damn boring game at the moment since our single room doesn’t even have a description so lets go back and change that.
The Office is a room. The description of the office is “A comfortable home office with a large mahogany desk and plush leather chair. The bookcase behind the desk is lined with leather bound books that give the office a classy feel while the black flat-panel monitor on the desk shows that the owner has not been left behind by technology. The bedroom is to the north and the bathroom to the east.”
In many cases Inform will allow you to do the same thing in different ways so if the above is a bit too verbose then you could shorten it to:
The Office is a room. The description is “A comfortable . . .”
The Office is a room. “A comfortable . . .”
All three of these produce exactly the same effect. What isn’t optional is the format of the lines. Notice that “The Office is a room.” is a complete sentence, ending with a period. The description (whichever option you choose) is a separate sentence also ending in a period. Try taking out the first period and clicking go if you want to see what that error screen I mentioned above looks like in action. Just about every new thing you do should end with a period. Missing periods and quotation marks are often the cause for error messages that you get. Note that the information that you actually want to be printed is enclosed in quotation marks and this is the case for pretty much everything you want printed on the screen. The interface helps by color coding the different kinds of text so that it’s easier to make sure you have everything right.
Our description mentions some other rooms so let’s set one of those up real quickly here. To set up which direction leads where it’s as simple as just stating it.
The bedroom is a room. The bedroom is north of the office.
Actually, you don’t even need that first sentence there. The reason is that when you say something is north (or any direction) from a room, Inform assumes you are talking about another room. You could actually be referring to a door as well but for now don’t worry about that. As simple as doors might seem to us, who use them every day, for the moment they are a complication best left for another time. At any rate, Inform will first try to match the name with an existing room but if it doesn’t find one, it will just create it for you (now isn’t that helpful of it?). So all you really need to write is:
The bedroom is north of the office.
And if you hadn’t already created the office, that sentence would have created both rooms. How’s that for streamlining things. Personally, I don’t use that particular shortcut since I like to keep my rooms separate and don’t like them overlapping like that in my code but use whatever method you like. I didn’t give the bedroom a description because we won’t really be doing anything with it here but you would just add it like you did the office above. You can now compile the game and go north to get to the bedroom and then south to get back to the office. Notice that you didn’t explicitly state that the office is south of the bedroom but in the absence of any other information Inform assumes that the return path is the opposite direction. I’ve used the word ‘assumes’ a couple of times now. Inform is constantly making assumptions based on what you write and it is usually pretty good at getting things right but always double check by testing your game. Inform might assume, but it’s a bad idea for you to do so. I’ll let you make the bathroom yourself if you want and we’ll get back to the office.
So now we have a nice little room description of the office and if you compile the game and run it again it should pop right up and also print again when you type 'look' or 'l'. Of course if you try to examine any of those lovely things we mentioned in the description we are going to run into problems since we haven't bothered to create any of them yet.
Interlude 1 -- Kinds
Before we get down to making some objects, now seems like a good time to explain a bit about how Inform organizes the world. Anything you create will have something that Inform calls a 'kind' and when it comes down to it there are only three 'kinds' in the program. They are room, thing, and direction.
Direction is quite a bit different than the other two and is something that you will almost never need to mess with so I won't say anything else about it here. Room, as you might expect, is for all the locations that you create. Look back at the office description and you can see how we made it a room.
This leaves just 'thing' left. Everything else you create in your game, every single physical object will be a thing. The desk and chair we are about to create are things. The clothes that the characters wear (if they wear any), their body parts, and in fact, the people themselves, are all things. Doesn't seem like a lot to work with does it? Luckily, Inform allows us to be quite a bit more specific. For example, when we get around to making our love interest we wont say 'Kes is a thing,' we'll say 'Kes is a woman.' 'Woman' is a kind, which is why we are allowed to create her this way. It is actually a sub-set of the 'person' kind, which in turn is a sub-set of the 'thing' kind so you see how everything works back to that point.
The ‘woman’ kind is actually one that is built in, but Inform has very few of these pre-built kinds. One of the neat things about the program is that we are allowed to make our own kinds anytime we want to. For instance, lets say we are writing a larger game and we want to divide all the women into two categories. Every woman in our game is going to be either a virgin or a whore. Yeah, I know, ridiculous, demeaning, sexist attitude but go with me. One way to do this (probably not the best way but just as an example) would be to make these new kinds. We would do it like this:
A Virgin is a kind of woman.
A Whore is a kind of woman.
You can follow the path back the same way as before (Virgin-Woman-Person-Thing) so it always finds its way back to 'thing.' This allows us to create the women in our game like so.
Betty is a virgin.
Veronica is a whore.
When we build on an existing kind like this the new kind will have all the characteristics of the one it is built on so the game will still understand that Betty and Veronica are women and treat them accordingly. However, in addition to those characteristics, we are now allowed to add our own that will only apply to the virgin or whore sub-set of the ‘woman’ kind. If this seems confusing, don't worry about it. We'll talk more about it as we go along and I'll also explain why doing it like this probably isn't the best way in this particular case.
Now, back to our office. Creating objects is just about as easy as creating rooms but there are a few things you need to keep your eyes on. Let's take a look at that desk and I'll show you what I mean. You can create the desk like this:
The desk is a thing in the office. The description of the desk is "A huge mahogany desk, polished to a mirror-like sheen."
Again, there are shortcuts you can use to cut a few words off here and there but it's always safe to be more verbose. Notice that we stated that the desk is in the office. If we hadn’t said that, Inform still would have created the desk but it would have started life out of play (in no room). We could then later move it wherever we want it, which is sometimes what we want but if you want a thing, person, whatever to start in a certain room, you have to say so. If you compile the game again you will find that you can now examine the desk but there are a couple of other problems. If you try taking the desk, the program will have no problem with this at all, which is ok if your PC is the Incredible Hulk, but it's probably not what we we’re after here. The reason for this is that every 'thing' is either portable or fixed in place and by default, Inform assumes it is the former. That is easily fixed however, just add the following sentence after the desk description.
The desk is fixed in place.
Now if you try to take the desk you will get a suitable (if rather boring) response saying you can't do that. There is a second problem with doing it this way that you have already noticed if you are actually typing this in as we go along. When you first start the game it prints the room description that we wrote above and then adds a line at the end saying, "You can see a desk here." This has the effect of mentioning the desk twice, which is probably not what we want. You could take out the reference to the desk in the room description but I think our description sounds better than "You can see a desk here" so there is an alternative. Just add the following line.
The desk is scenery.
This basically tells Inform that we don't want it to mention the desk in a sentence of its own. You will probably be using 'scenery' a lot so get used to it. Another nice thing is that anything classified as scenery is assumed to be fixed in place so we no longer need that bit of text. You can leave it in if you really want to but it no longer does anything and just adds extra text. In fact, it's possible to cut down on what we've written quite a bit. The following does everything that all the lines above did.
The desk is scenery in the office with description "A huge mahogany desk, polished to a mirror-like sheen."
You'll learn some of the shortcuts as you go along but like I said, you can't go wrong by being a bit more wordy. You should also note here that it looks like we are saying that the desk’s kind is ‘scenery’ but that is not the case. Scenery is an add-on and this is one of the only cases when we can create something without explicitly stating it’s kind. Scenery is used so often that Inform allows the shortcut in this case but if the object we are creating is anything other than a basic ‘thing’ we could not do it this way as we’ll see in a moment.
So is that it? Is our desk perfect now? Well, not quite. To experiment a bit let’s add another object to the game and see what happens.
The apple is a thing in the office with description "A shinny red apple."
If you're actually typing this in as we go along then play around with the apple and desk a bit and see what happens. Go ahead, I'll wait.
hum-de-dum-dumm, hum-de-doo-doo, hum-de-dum-de-doo.
Ready? So what did you find? First off, you should notice that the room description makes mention of the apple. In this case that is just what we want so it’s fine. Also if you take the apple and then look it won't say anything about the apple. This is also what we want since it would be annoying to have the player's inventory listed in every room description.
That's what's right, so what's wrong? Well, if you play around a bit with this very simple game you will notice at least two things and while the solutions are different, the problem in both cases is, at least somewhat, the same. The first problem is that you can't eat the apple. The second is that you can't put it on the desk. This is where the illusion that Inform 7 is not a programming language starts to break down. We have been creating our game by writing nice little English sentences so the temptation is to think that the program understands English -- it doesn't. The problem here is that Inform has absolutely no idea what an apple or a desk is. It doesn't know that you should be able to eat an apple or set things on a desk unless we tell it so. The apple is an easy fix, just add the following line.
The apple is edible.
Inform still doesn't know what an apple is but at least now it knows that the player should have the option of eating it if he wishes. The desk is a little different situation. Remember our talk a few minutes ago about kinds? How 'woman' was a sub-class of 'thing'? Inform has a few more of these sub-classes built in and one of these is 'supporter.' As the name suggests, this is something that you can set other things on, which is what we want for our desk so we need to do a bit of rewriting. For the moment, ignore the shortcut method I showed you and go back to the original desk description. All you need to do is change:
The desk is a thing in the office.
The desk is a supporter in the office.
Now compile the game again and try it out. Be sure you try putting the apple on the desk before you eat it because once you eat it, it's gone. Everything should work pretty well now. So are we done with this nasty, hateful desk yet? Well, we could be but in addition to setting things on desks, most of them have drawers that we expect to be able to put things into. How do we handle that?
Another of Inform's built in kinds is 'container' which, as you may expect, is something that you can put things into. So how do we make the desk both a supporter and a container? Actually, we can't. Every object you create can have one, and only one, kind. Thinking back to our discussion on the 'woman' kind you might be able to make an argument that this is actually three kinds (woman, person, and thing). In that case, it's all right since each builds on the prior one but container and supporter are two completely different kinds and Inform will have a hissy fit if you try to make the desk both. Go ahead and try it if you don’t believe me.
However, you will be happy to know that there is a way around this. When you put something into a desk, what you are usually putting it into is a drawer, not the desk itself. So all we need to do is to make a drawer and make it a container. We could do this by simply making the drawer a container in the office like we did the desk but Inform allows us to be a bit more elegant about it.
The drawer is a container. The drawer is part of the desk.
This has the effect of attaching the drawer to the desk rather than making it a freestanding object in the office. In this case, since the desk will never move, it probably doesn't matter all that much (assuming we also make it so the drawer can't move). But let's say our PC really was the Incredible Hulk. It would seem a bit strange to pick up the desk and move it to the bedroom only to find that the drawer was left behind in the office. Like I said, it probably doesn't matter in this case but it's a good habit to get into and it just makes more sense.
Ok, so now you have a drawer that you can put things into but if you took the time to compile the game again you would notice yet another problem. You can take the apple and put it in the drawer but you cannot close the drawer. Again, this is because Inform has no idea that a drawer should be able to be opened and closed and by default, a container is always open and cannot be closed. Think of a milk crate instead of a drawer. This is certainly a container but it would be strange to talk about it being open or closed. If we do want something that can be open and closed then it's no problem, we just need to tell Inform that's what we want. To do this we need to give the drawer a couple of properties. Here is the first one.
The drawer is closed.
This gives the initial state of the drawer but still does not let us open or close it, which in this case is just not very helpful so we need one more.
The drawer is openable.
Now everything should work how you would expect. The drawer will be closed when the game starts but the player will be able to open it, put the apple inside, and then close it again. And that, finally, concludes our work with the desk. There are probably a couple of other things that you might want to do with it but it will now behave more or less like you would expect a desk to behave. It may seem like a lot of work but explaining how to do it took quite a bit more time than actually doing it and most of the object you create will not be nearly this complicated.
To round out some of the basic items let's make that leather chair. Chances are good that you will want a chair at some point so this is a good thing to know. Basically, all you need to make an item that the player is allowed to sit on is to make a supporter and then give it the property of being 'enterable.' This tells Inform that it is something that the player should be able to sit on. So to make our chair we would write the following.
The leather chair is a supporter in the office with description "A plush leather chair. It looks very comfortable."
The leather chair is enterable. It is scenery.
Don’t forget to make it scenery. Inform will read ‘it’ here as referring to the chair since that was the most recently created object but you could, of course, spell it out if you like. “The leather chair is scenery.” And there you go, you can now walk up to the chair and have yourself a little sit down. But what if you wanted to have several chairs in your game? Well, you could just make them all like the one above, being sure to add that each one is enterable, but this is a good example of where creating our own kinds can save some time. We could do it this way instead.
A chair is a kind of supporter. A chair is usually enterable. A chair is usually scenery.
Then, to created our chairs we just have to write:
The leather chair is a chair.
The couch is a chair.
The barstool is a chair.
Or whatever, and they will automatically be enterable and scenery. Did you catch that 'usually' word that we used when we made our chair kind? Whenever we make a condition like this we are allowed to use one of four words, always, usually, seldom, or never. We could have used the word always above and it would have worked just as well but it's just a tad risky to use the words always and never in these situations. The reason is that they leave no room for change. In this case, I'm having a hard time thinking of a situation where you would want to create a chair that the player cannot sit on, but if you did and if you had said always instead of usually, then you would not be allowed to do so. Using usually means that Inform will assume that any chair you create will be enterable, unless you say otherwise. If you had said always, Inform would not let you say otherwise and will give you an error message if you try. The moral here is that if you use the words always and never, be very sure that it is actually what you mean.
Interlude 2 -- Properties
I've thrown a word around a few times now and I think I had better explain it. I've talked about giving an item a property of this or that so what exactly do I mean by property? A property affects the way something behaves and unlike kinds, something can have any number of properties. Most of the ones we have used so far have been either/or properties.
A container can be either open or closed, either openable, or not openable. A supporter can be either enterable or not enterable. A thing can be either edible or inedible. There are a lot of these built in that can be used but again, we are allowed to make our own.
As an example, let's get back to our virgins and whores. Oh I like the sound of that. With you permission, I think I'll just say it again. Let's get back to our virgins and whores. Anyway, you may recall when I said how we did this probably isn't the best way to handle it and here is what I meant. The way something is created is by giving it a kind. In addition to the fact that an object can only have one kind, it also has that kind forever. This is important so pay attention, once you give an object a kind it cannot be changed -- ever. Our desk is a supporter, now and for always. The drawer will always be a container and the apple with always be a thing.
So does that mean that we will always be able to open and close our drawer? Not necessarily. Let's say that at some point during the game someone nails the drawer shut. Now the drawer cannot be opened (at least not without a crowbar or something). We would then tell Inform that when that happens the drawer is now not openable. Did we change the drawer's kind? No, we just changed one of the properties that we had given it from 'openable' to 'not openable.' It's still a container, just not a very useful one at the moment. Maybe later in the game the player will find a crowbar and be able to open it again. We then just change it back to 'openable' and on we go.
So are you beginning to see some of the problems with our virgins and whores the way we set them up? If not, let me explain. What happens when you engage in sexual intercourse with a virgin? Well, depending on how old she is there might be some jail time involved, but assuming she's of age the most basic thing that happens is that once the deed is done, she is no longer a virgin. The way we set it up before there would be no way to change this. Once a virgin, always a virgin, which is a bit unrealistic to say the least. Now that we know about properties we have a much better way to handle it.
A woman can be a virgin or a whore.
This creates a brand new either/or property that applies only to women. Set up this way, we would not be able to refer to a man as a virgin or whore, only women. If we did want it to apply to the males in our game we could have said 'a person' instead of 'a woman.' Now let's create our girls again.
Betty is a woman.
Veronica is a woman.
Betty is a virgin.
Veronica is a whore.
The first two sentences above create the girls and the second two give them their respective properties. Note that the order you go about this is important. If you try to say that Betty is a virgin and you haven't specified what a virgin is or that Betty is a woman you will get an error message. Now when you get around to doing Betty you just add a line at the end saying: Now Betty is a whore. And bingo, she's de-virginized. Also note that you are by no means limited to two options when creating properties. Maybe we can admit that just because a girl is no longer a virgin, doesn't necessarily make her a whore. We could have set up our property like this.
A woman can be a virgin, a non-virgin, or a whore.
And we can then freely change the property as we go along. We are even allowed the god-like power of turning a whore back into a virgin if we so desire but that's a different story.
I can see that this is running a bit longer that I had anticipated and I can almost hear Mr. Ninny clucking his tongue at me so the rest will have to wait until next month but let me just sum up some of what we've learned today.
Everything you create will have a kind. A room or object can have only one kind and that kind will never change. To create something you simply call it it's kind.
The office is a room.
The desk is a supporter.
The drawer is a container.
Betty is a woman.
In addition to the kinds built into Inform we are allowed to created our own, giving them properties that will apply to the entire kind, rather than just a single object.
A chair is a kind of supporter. A chair is usually enterable. A chair is usually scenery.
In addition to it's kind, anything you create can have any number of properties and these can be changed as often as necessary during the course of the game. To give an object a property we just say that it is true.
The drawer is closed.
The apple is edible.
Remember that to give something a property it's kind must allow it to have that property in the first place. For instance we would not be able to say the following.
Betty is closed.
Because Betty is a woman and the open/closed property is not one that can be applied to people. In addition to properties that are built in to Inform, we can create our own at will.
A woman can be a virgin, a non-virgin, or a whore.
We can then use this property just like any of the other ones.
I know we covered a lot of ground this month but you now have enough information to do a pretty good job of creating your physical world. You can create all your rooms and put the props in place. Work on that for this month and next month we'll learn how to change the initial state of things and talk about the sex. Until then, work hard, have fun, and think dirty thoughts.
Go To Part 5
|Home | My Stuff | Resources | Links | Contact Me|