One Night Stand: Part 5
Home
My Stuff
Resources
Links
Contact Me
I've been trying to decide what to include in this tutorial.  There are a lot of cool things about Inform that I am tempted to go into but when I think about the scope of our project I realize that most of them are not strictly necessary and the purpose of this tutorial has never been to be a comprehensive manual on all of Inform's various features.  If that is what you want then there is already a very good one built into the program.  The purpose of this tutorial is to give the first time author the tools they need to complete a simple game while hopefully not overwhelming them.  After all, once you have the basic tools down and a game under your belt then taking the next step to learn the more advanced stuff should be much easier.  With that in mind I have decided to concentrate on the essentials, only going into the various features of the program when they come up directly (or at least that's my plan for the most part.  No actual promises there).

Last month we learned how to make basic rooms and object.  This is obviously one of those essential skills I was talking about since no game gets very far without someplace to stand and a few things to look at.  We also briefly discussed creating people and found that the process is much the same as creating other objects.  Since most of this part of the tutorial is going to be on sex, we are going to need someone to practice on so if you're following along as we go (and I encourage you to do so) then let's make someone to play with.

Lisa is a woman in the office.  The description of Lisa is "A perky little blond with a love of life and sex."

We'll be doing more with Lisa (much more, heh, heh, heh) in a moment.  As I mentioned, the bulk of this lesson is on sex, which is really what it’s all about right?  At the beginning of this tutorial I told you that I would be making a simple extension available for basic sexual commands.  Well, I'm a man of my word and the extension is now ready.  You can now download it from my files page.

So what exactly is an extension and how does it work?  An extension is a section of code written by someone else (or yourself) and added to your game.  It is usually used to accomplish a particular goal without the need to write the code yourself.  They are especially helpful when you are first starting as they save you the time it would have taken you to do it yourself and if someone has already done what you are trying to do, there is really no need at this point to try and reinvent the wheel.  To use an extension you first have to install it into Inform.  You can put the extension anywhere on your computer that you want to although it is usually a good idea to keep them all together.  Then simply load Inform, select ‘install extension’ (in the windows version it is under the file menu), find the extension you want to install and click open.  This does NOT add the extension to your game.  It simply makes Inform aware of its existence and lets you see a summary and documentation of it (if available) under the ‘Installed Extensions’ section of the documentation page.  When you are ready to add it to your game you just need to add a single line of text (usually right at the beginning of your code) like so:

Include Basic Fornication by Purple Dragon.

And that’s it.  The above line is all that will be listed in your source text.  The full text of the extension will not be on the screen to clutter up your code (you can view it if you want from the files menu), but now every time you compile your game Inform will also read the contents of the extension and add the functions defined there to your game.  So what the hell does it do anyway?  I have tried to strip this down to the bare minimums.  It defines the basic body parts and sexual commands necessary in most AIF games.  Remember a couple of months ago when we talked about adding extra body parts and commands?  Well none of those are included, allowing you to make this first game a very simple one.  Of course, if you do want to add more then you can certainly build on what I have done yourself.  Keep in mind that this extension assumes a male PC and a Female NPC.  If your PC is female the extension WILL NOT WORK.  Here is what is included in the extension as it stands.

For women it defines the ‘big three’ body parts: tits, ass, and pussy.  For guys it defines the “big one” or in my case the “REAL big one” if you know what I mean? (wink, wink, nudge, nudge).  Anyway, if you want to add others it’s pretty easy to do so.  The extension itself includes documentation that explains how to do this so I won’t go over it here.

As far as the sexual commands go, again I have just included the basics.  The player can rub, lick, and fuck people and body parts.  He can kiss people but any attempt to kiss a body part will redirect the command to licking it.  He can titfuck and assfuck people but again, these commands are simply redirected to “fuck [person’s] tits” and fuck [person’s] ass” respectively.

What all this means is that at the minimum, you need to write one response for every combination of rub/lick/fuck [girl’s] tits/ass/pussy.  I did put in handling for basic responses but since the most exciting this gets is something like “You rub Lisa’s tits” you will nearly always want to override these defaults.  So the question is, how do you do that exactly?  There are probably a dozen different ways that you could do it but I’m going to focus most of the rest of this article on what may be the simplest of them.  However, before we get to that I think we should pause to take a look at how Inform handles actions and how you write rules for them in general.

Actions and Rules

Actions are basically what happens when the player enters a command (gross oversimplification there but it will work for the moment) and it is important to know how to refer to them when writing rules.  For instance, look at the apple that we created last month.  If the player types:

>take apple

then the action we refer to is:

Taking the apple.

It is written using the present participle, which is a fancy way of saying we write it as though it is happening right now.  Whether the player actually typed “take apple”, “get apple”, “pick up apple”, or whatever doesn’t matter.  The action is still “taking the apple.”  Two things can happen when the player attempts an action, it can succeed or fail.  Like if the player tried to take the desk the action would fail because we have fixed it in place.  There are a lot of reasons why an action might fail and we won’t go into them all right now but just keep in mind that it could very well happen.  When an action succeeds, a list of things defined for that action happen that can be as simple or as complex as we want to make it.  In the above example, what happens is that the apple is transferred to the player’s inventory and game simply prints out “Taken.”  If this is all you want to happen then there is nothing more to do, but what if you want something a bit different?

There are three kinds of rules (actually there are more than three but for now we’ll just talk about three of them) that you can apply to an action to modify how it works called before, after, and instead of.  It should be pretty obvious, at least in a general way, what these do.  Before rules make something happen before the action, after rules do something after it succeeds, and instead of rules bypass the action altogether and do something different instead.  Here are some examples of how you could use these with the apple.

Before taking the apple:
    Say “You look around to see if anyone is here to claim the apple as their own.  When you see no one, you reach down to pick up the delicious looking piece of fruit.”

This is an example of a rule and you will be writing a lot of them so note the format.  You start with the rule itself, “before taking the apple” followed by a colon.  What follows is a list of things that you want to happen and each of these ends with a semicolon until the last, which ends with a period (or exclamation point or question mark).  In this case there is only a single item that tells the program to print the following text on the screen so there are no semicolons.  When you have a rule like this with only a single thing in it you are allowed to shorten it by replacing the colon with a comma like so.

Before taking the apple, say “You look around...”

Just remember that it only works if there is just one thing in the list.  If you have more that you want to do, you have to use the longer method like this example of an after rule.

After taking the apple:
    Say “As you pick up the apple you realize why no one had claimed it and you drop it like it was a hot coal.  Unfortunately, the damage has already been done and you can feel the potent poison working its way into your blood stream through the pores in your fingertips.  Your last thought before collapsing to the ground is that you always knew that fruits and vegetables would kill you someday.”;
    End the game in death.

The line breaks and indention are optional but they help with readability once you have a bunch of rules in your game. Notice the ‘say’ commands in both of the rules.  All this does is tell the program that you want it to print out the following text on the screen.  In fact, this is pretty much the pattern for all the parts of the rules.  It is all written as if you were giving instructions to someone.  I suppose that the trick is knowing which instructions to give when but that will come in time.

The last of our three rules is the ‘instead of’ rule and it’s a bit different than the other two.  Not in the way you write it, but in the way it acts.  Let’s look at an example and then we’ll talk about it.

Instead of taking the apple:
    Say “You have always had a secret belief that fruits and vegetables are of the devil and as you look down at the apple you can’t imagine why you would want it.  I mean, if it were a Snickers bar sure, but an apple?  No, I don’t think so.  Maybe it’s your distaste of such things that makes you do it, but you take one more look and then give it a swift kick, watching as it sails out of the window and away.”;
    Award 5 points;
    Remove the apple from play.

Here we gave the program a couple of other instructions.  We told it to give the player 5 points for his foresight and to then get rid of the apple.  You can add as many of these commands to your rules as you want.  The thing I wanted to mention here though is the way that instead rules differ from before and after rules.  I said before that every action ends in either success of failure.   In our first two examples, the action ends in success (although in the second case the player probably would have wished it didn’t).  In contrast, instead rules always end in failure.  This isn’t necessarily a bad thing but from the program’s point of view, the action that was attempted did not succeed.  I mention this now, not because it is anything you need to do something about at the moment, but because it will become important later on.

Ok, so why did I go into all that when I just got through saying that we were only going to concentrate on what you need to get this game done?  You may have thought that I had a plan in mind, or you might just think I like to hear myself talk (type?).  Well for your information I do have a plan in mind and it involves how we are going to make all those lovely sexual commands work so let’s get back to it.

Instead Of Sex

I said before that there are many different ways to write the sex in your game and that is definitely true, but the one I’m suggesting you use (at least mostly) this time, is the instead rule.  This certainly isn’t the most elegant way to handle it but it is perhaps the easiest since what you learned in the previous section is almost all you need to know.  We’ve learned how to refer to actions so if the player types “kiss Lisa” then the action we are talking about is “kissing Lisa.”  Now all you have to do is write a rule like the following.

Instead of kissing Lisa, say “You press your lips to hers and feel her body melt against yours.”

Just to be clear here, with the extension the way it stands and without adding any extra body parts or actions, here is a list of the actions that you would have to write.  Obviously you would substitute the name of your own girl for Lisa’s in the following.

Kissing Lisa, rubbing Lisa’s tits, rubbing Lisa’s ass, rubbing Lisa’s pussy, licking Lisa’s tits, licking Lisa’s ass, licking Lisa’s pussy, fucking Lisa’s tits, fucking Lisa’s ass, fucking Lisa’s pussy.

This is exactly the way that you would need to refer to them.  Even through there are synonyms for all the body parts and actions, you have to use the ones listed above because these are the ones I set up as the actual part/action.  The player is allowed to refer to the synonyms to their heart’s content but you are not.  If you simply can’t abide referring to something the way I have written it (let’s say you just hate the work ‘tits’ for some reason) then feel free to go into the extension and change it.  Just change the name of the body part to the word of your choice and don’t forget to then add ‘tits’ in as a synonym.

To round out the actions available, the extension also allows the player to ask the girl to do things.  He can ask her to rub her own body parts, rub, lick, and fuck his cock, and kiss him.  Here is the wording you need to use.

Instead of asking Lisa to try rubbing Lisa’s tits…
Instead of asking Lisa to try rubbing Lisa’s ass…
Instead of asking Lisa to try rubbing Lisa’s pussy…
Instead of asking Lisa to try kissing the player…
Instead of asking Lisa to try rubbing my cock…
Instead of asking Lisa to try licking my cock…
Instead of asking Lisa to try fucking my cock…

The reason that you use the words “my cock” is explained in the extension as well so you can read it there.  You will probably be tempted here to try writing something like, “Instead of asking Lisa to rub my cock.”  But that will not work for a couple of reasons.  First, the action is “rubbing [body-part]” so “rubbing Lisa’s tits”, “rubbing my cock”, etc.  Second, the word ‘try’ is very important here since there are things that might get in the way of the NPC doing what you are asking.  I don’t want to bog you down too much so just take my word for it for the moment and write the commands as above.

While we’re on the subject of asking someone to do something we should probably talk about persuasion for a moment.  In order for someone to carry out the player’s request for them to do something they normally have to be persuaded to do so.  In the absence of any other information, all NPCs will refuse to carry out all orders by the player.  To change this behavior you need to add a persuasion rule like the following.

A persuasion rule for asking someone to try doing something:
    Persuasion succeeds.

Of course, this rule makes any NPC willing to do anything at any time and is usually something that you would only use in testing the game to make sure everything works ok.  In practice, it’s too open ended to be of much use.  As it turns out though, since we are using the instead rules this doesn’t matter as much.  Remember that instead rules override whatever the action is supposed to do in favor of the instructions that you put in that particular rule.  In short, this means that the program will never get to the point of checking to see if the character’s persuasion will allow the action because they will never reach the action in the first place.  A word of warning here.  If you are going to forgo any kind of persuasion rule then you have to make sure you put in an instead rule for every one of the above actions.  The default replies I put in will be blocked by the absence of persuasion and the rejection that prints is “Lisa has better things to do.” Which is not really what the player wants to hear.  I think you should be fine doing it this way since you should be entering unique text for all of them anyway.  Even if you don’t want to include a particular one you should still write a response saying why the player can’t do that.  For example, if you have an aversion to anal sex and don’t want to include it, that’s fine.  Just write the instead rule like normal, saying why he can’t engage in that particular activity.

So at it’s simplest, that’s it.  By my count that gives you 17 responses that you have to write and you are done.  Of course, that is going to make for a very short game since, if you do it as above, the player will be able to start in on the sex right away and there will always only be one response for each action.  If you want to get a bit more in-depth with it then we don’t have to throw out the instead rules, we just have to modify them a bit.

Last month we created two rooms in our little sample game, an office and a bedroom.  Let’s say that we only want our responses displayed if the Lisa and the player are in the bedroom.  All you have to do is change the instead rule a bit to make that happen.

Instead of kissing Lisa in the bedroom:
    Say “You press your lips to hers and feel her body melt against yours.”

Now the response will only be displayed in the bedroom, not in the office.  But what if the player does try it in the office?  If you are using the persuasion rule then in the absence of anything else, it will display my boring default responses.  If you aren’t, it will say that Lisa has better things to do.  Since you probably don’t want either one of these then we’re going to have to do something about it.  You could just write a rule for the office as well.

Instead of kissing Lisa in the office:
    Say “Lisa is an old fashioned girl and usually reserves those kinds of actions for the bedroom.”

That will work fine but then you would need to do the same for all the other actions.

Instead of rubbing Lisa’s tits in the office, say “Lisa is an…”
Instead of rubbing Lisa’s ass in the office, say “Lisa is an…”

And so on.  For situations like this where you want to talk about all the sexual commands at once, I have grouped them together in the extension under the heading “being sexual,” which means that all you have to do is write,

Instead of being sexual in the office, say “Lisa is an…”

And that will handle all the commands at once.  Neat huh. (Note that I blatantly stole this wording from A. Bomire’s Bob’s Garage game.  Originally I had set it up as “intimacy”, which worked fine but I kept forgetting how to spell the damn word and besides, “Instead of being sexual” just sounds better than “Instead of intamacy.”  Shit!  See what I mean about the spelling?  Anyway, thanks AB).

So now you have limited all the sex to the bedroom and maybe the puzzle is how to get her into the bedroom so that you can start.  Well, it’s a good start but what if you want to include more than a single response for each action?  It’s easy to do with just another modification of our instead rule.

Instead of kissing Lisa in the bedroom for the first time, say “You press your lips to hers…”
Instead of kissing Lisa in the bedroom more than once, say “You kiss her again.”

You have to be a bit careful with your wording here.  If you had written “for the second time” instead of “more than once” then it would have printed your response the second time the player kissed her but then reverted back to the defaults for the third and following times.  You can add as much here as you want.

Instead of…for the first time…
Instead of…for 2 to 3 times…
Instead of…for four to six times…
Instead of…for the seventh time…
Instead of…for the 8th time…
Instead of…for more than 8 times…

And so on, just make sure that the final rule takes into account all future attempts.  Also notice that I switched back and forth between spelling out the number and using the numerical digits.  You are allowed to spell them out up to ‘tenth’ after that you would need to use “11th”, “12th”, etc.  Of course, in this particular case I doubt you will reach that limit so it may not matter.

Now if you had a different room where you also wanted to allow sexual conduct you could write a whole new list the same way and it keep them nicely separated.  Something to watch out for when talking about the number of times is that we are counting the number of times the action has been attempted, not the number it has succeeded.  Remember that when writing “instead of” rules that the action never is completed but this does not stop the program from counting attempts.  For instance, it may have occurred to you that since you blocked the sexual commands in the office, that if you only have one other room then there would be no need to specify it as above.  Unfortunately this isn’t true for a couple of reasons.

The first is that if you write two instead rules, for example:

Instead of being sexual…
Instead of kissing Lisa…

Then both of these would be valid rules. So how does Inform decide which to use?  The answer is that it will use the more specific of the two and since “being sexual” is a grouping including kissing (as well as other things), in this case the “kissing Lisa” rule is the more specific and the “being sexual” rule would be ignored.  You can get around this one by rewriting the being sexual rule as a before rule like this:

Before being sexual in the office:
    Say “Lisa is an…” instead.

Since before rules beat instead rules to the punch, so to speak, this will solve that first problem but unfortunately, it still leaves the second.  Even though it will now block all attempts to kiss Lisa in the office, the program will still count up the number of times it was tried and when the player does get to the bedroom, it will start on that number on your list instead of at the beginning.  There are ways around this too as there are ways around just about anything but the simplest way for the moment is just to specify the room in each rule.

You may be wondering if it is possible to make sex in the office prohibited at the beginning but ok later on.  The answer is, of course so, but because of the counting thing with the instead rules it’s a bit more complicated if you want to include multiple responses so for now, save the sex for other rooms.  So how are we going to get Lisa into the bedroom?

Again, there are a lot of ways to handle this but let’s take a look at what we have to work with.  In our original description of the office last month we mentioned a computer (well, a monitor actually but you would have to assume there was a computer around somewhere).  Let’s say that the game started by Lisa calling the player in to fix her computer.  Sure, it’s not quite as cliché as a plumber but this is the computer age right?  And everyone knows that when a repairman of any kind is called in to do repairs that he has the right to expect the sexual attentions of the lady of the house once his job is done.  Let me pull my tongue out of my cheek and we’ll see if we can’t get that computer fixed.

So far we have only been using actions either built into Inform or from the extension but sooner or later you are going to need to make one of your own so here is how you do it.  A lot of this isn’t going to make perfect sense to you at the moment but if you copy the form for now, you should be ok.

Repairing is an action applying to one thing.  Understand “repair [something]”, or “fix [something]” as repairing.

At it’s most basic, that’s all there is to it.  The first sentence above defines our new action as “repairing”.  The second sentence tells Inform what the player will be typing in to trigger the action.  You can add as many synonyms here as you like and it is usually a good idea to put in everything you can think of and then have the game beta tested and add everything that your testers can think of as well.  Doing something like this wrong is what leads to guess the verb problems and those are never a good thing.  Notice the square brackets above.  This is where we specify the kind of thing that the action can apply to.  In this case, [something] means that the player can attempt this action on any “thing” kind, which basically means any item in the game.  Normally we would want to add some rules for when the player attempts to repair something inappropriate.  For instance, it really doesn’t make any sense to try to repair a person or something that isn’t broken.  For now, we’ll just put up with the errors and get right to fixing the computer.

Of course, before we can fix it, we have to create it.  I’ll leave this up to you to do, just remember to add all the synonyms you can think of.  You do this in the same way as above, adding a line like the following to your computer item.

Understand “CPU”, “Monitor”, or “hard drive” as the computer.

You would probably want more than that but you get the idea.  Now that we have our new action and something to repair, we can write our rule like normal.

Instead of repairing the computer:
    Say “You look behind the computer and notice that the plug has come out.  You make a show of looking like you’re doing something but then just plug it back in and turn on the power.  Lisa looks over your shoulder and squeals in glee, ‘Oh, thank you so much for fixing my computer, now if you come into the bedroom I have something else that could use your attention.’  So saying, she turns and leaves the room, glancing once more at you over her shoulder as she goes.”;
    Move Lisa to the bedroom.

One new thing here is the single quotation marks in the say command.  Since you are using double quotes to tell to program to print something, you can’t use them inside the block of text.  When you use the single quotes like this Inform will automatically convert them to double quotes in the game.  Well, there are actually a few problems with this as it stands but I think we’ll skip them for the moment.  For now, we have Lisa waiting in the bedroom, which is where we want her, and the player just has to walk in there and sex her up.

I’m sure you have a lot of questions but we simply don’t have the space to go into everything right now.  You should be able to use the tools here to write at least most of a basic game and that is what we were after with this tutorial.  If you would like a slightly more advanced discussion and a few more examples of how to get around some of the problems that what we did just created I have written up a small sample game, which you can also download from my files page.  First let me say that this is not really a game so if you are not trying to figure out how Inform works then there is really no reason to download it.  It is actually the source text, which means that you will need the Inform program to compile it, but this will let you see all the text and my comments.

Well, that’s it for this month.  Next month I hope to wrap things up with a discussion of clothing and conversation but if you have any specific questions in the mean time just let me know.  I’ll see you next month and until then, work hard, have fun, and think dirty thoughts.

Go To Part 6
Home | My Stuff | Resources | Links | Contact Me