Few quick questions from a beginner

Hello, I’ve just started messing with Inform 7, and while I’m getting the hang of it, there’s still a few things I haven’t entirely figured out. Sorry if these have already been covered in the documentation, but if they have, I haven’t found it yet.

  1. I’d like to make it so the player sees an object under a dresser, but, when they try to take it, they’re told they’d have to crouch down first. Once they do, they’ll see that an object is a coin, and can, while they’re crouched, be taken. How would I handle this? ‘The coin is under the dresser’ doesn’t seem to be what Inform wants.

  2. How do I make it so the game reacts to a specific word differently than what’s previously defined in the engine? If the player uses, say, a curse word, I’d like to change the default message.

  3. How do I make an event happen in a room 5 or so turns after the start of the game? I’d like to make it so that a character starts the game in a locked room next to the starting location, then, when the event starts, he unlocks the door, opens it, and moves to the starting location. How would I go about doing this?

  1. It looks like maybe you want to define a “crouch” verb and just check to make sure the player is crouched when describing and taking the coin?
    For a structured way of hiding things under other things: see example 233, “Beneath the Surface”. Example 381 covers postures. Both of these examples are perhaps a bit overkill, but I think all you need is in there.

  2. Can you give an actual example of how you mean? When can the player curse, just out of the blue, as a command in itself (“Bugger!”) or more in passing (“unlock the frigging door”)? Or when talking to another character?

  3. See section 9.11 in Writing with Inform. Or to actually help you along, here’s one way of doing it:

[code]“number three”

the first room is a room. The cell is a room.

the cell door is a door. It is locked and closed. It is east of the first room and west of the cell.

A guy is a man in the cell.

when play begins: the breakout happens in 5 turns from now.

at the time when the breakout happens:
say “Something happens on the other side the door. There is some rattling with keys, the door swings open, and this guy walks in.”;
now the cell door is unlocked;
now the cell door is open;
move the guy to the first room;
[/code]

“breakout happens” is not a magic phrase, it could be anything. You can replace “the breakout happens in 5 turns from now” with “foodle groobles at 9:05 AM” and do “at the time when foodle groobles:” instead.

There are a couple of options for #2. Since swearing mildly and swearing obscenely are both actions, you can just say:

Instead of swearing mildly, say "Your response."

But the syntax you’re probably looking for is understanding a mistake (16.20):

Understand "damn" as a mistake("Your response.").
  1. Hmm… I think this is a bit too complicated for what I want. Basically, what I want is for the player to be able to crouch, and the game would check for that if he’s looking under the dresser. Having him be able to sit on things and such could be handled through the default Inform rules. I would like to make it so the game starts with him laying in bed, so how would I handle that?

  2. You know how curse words give the standard “Real adventurers…” response? I’d like to change that, to something like “Real adventurers do not use such language. But you remember that you technically AREN’T a real adventurer yet, so go right ahead.” (The plot is that your character is part of an adventurer’s college. :stuck_out_tongue:) So, yeah, I’m not entirely sure where Inform keeps its rules on cursing. And it would be for words used out of the blue.

  3. That worked, thank you. Is there a specific section that goes into the more ‘programming’-like parts of Inform? I mean, stuff like ‘The hat is in the room’ is easy, but I’d like to know more about how to handle ‘if’ situations.

Also, I’m having trouble getting Inform to differentiate between two different beds. One belongs to the player character, and can be interacted with fully. The other bed belongs to his roommate, and is just scenery. How would I write it so Inform sees them both as different things?

First, give yourself the ability to be crouched.

Yourself can be crouched. [Yourself is the name of the default player character.]

Then, define a new action (see ch. 12.7 in the manual) that makes you get crouched.

[code]Crouching is an action applying to nothing. [I.e. you don’t crouch anything, you just simply crouch.]
Understand “crouch” as crouching. [So players can use the command “crouch”.]

Check crouching:
if the player is crouched, instead say “You’re already crouching.”

Carry out crouching:
now the player is crouched.

Report crouching:
say “You crouch down.”

Before doing anything other than examining or taking [etc. etc. etc.] while crouched:
now the player is not crouched;
say “(first rising from your crouching position)”.
[Or see to it somehow that the player doesn’t remain crouched down the rest of the game.][/code]

Use katz’s first suggestion (instead of swearing obscenely, say “… go right ahead.”)

That’s Chapter 11 (“Phrases”) in the built-in manual (= Writing with Inform).

Give them different names: “your bed” and “Bud’s bed”–or whatever.

And another tip:
From inside the Inform program (the “IDE”), you can click the Index tab and then choose the Actions subtab to get a list of the internal names of all actions defined by both you and the Standard Rules. You’ll need to use those names to refer to actions in your source text.

One other suggestion (and this relates more to design than to coding): If a player needs to crouch in order to find whatever it is that you’ve hidden under the furniture, you probaby want to write your room description in such a way as to give him some clue that that’s what he needs to do. “Crouch” is not a “standard” verb (which is why, as others have discussed, you need to create the action and the corresponding command), but that also implies that it’s not something a player would generally think of trying unless you give him a reason to do so. You also might want to provide some synonyms (e.g., “bend,” “bend down,” etc.) for crouch, to minimize the likelihood that a player who has figured out what he needs to do will nonethless not hit on the right word to do it.

Of course, you could just leave the player on his own with all this, in which case your questions about handling of curse words would take on distinctly greater relevance. :wink:

Robert Rothman

I’ve gotten the ‘cursing’ part figured out, but I’m running across another issue. See, I want to make it so the player can make his bed. (There’s no real point to this, but I’m just sort of ‘testing’ myself by adding a lot of interactivity to this project.)

I’ve run into an issue, though:

[code]A bed is a kind of container. It is enterable.

Before making the first bed:
if the first bed is unmade
begin;
now the first bed is made;
say “You put in a tremendous level of effort hoisting the covers back onto the bed, carefully smoothing them back under the pillows. Why you do this, even though you know you’ll just make a mess of them again, you aren’t entirely sure.”;
stop the action

Understand “make bed” as making the first bed.

The first bed is a bed in Dormitory. The first bed is scenery. The first bed can be made or unmade. The first bed is unmade. The printed name is “bed”. The description of the first bed is “Quite possibly one of the best friends you’ve made during your time at the school. Sure, you hate the way the covers are stitched in, leaving your feet to roast under them. Sure, you hate the way one of the springs jab into your back if you lean into it a certain way. But, when it all comes down to it, it helps you get to sleep.[If bed is made]The pea-green covers are neatly straightened out.[Otherwise]The pea green covers are dangling over the edge of the bed where you left them.[END IF]”[/code]

The error I’m getting is:
Problem. You wrote ‘Understand “make bed” as making the first bed’ : but ‘understand … as …’ should be followed by a meaning, which might be an action (e.g., ‘understand “take [something]” as taking’), a thing (‘understand “stove” as the oven’) or more generally a value (‘understand “huitante” as 80’), or a named token for use in further grammar (‘understand “near [something]” as “[location phrase]”’). Also, the meaning needs to be precise, so ‘understand “x” as a number’ is not allowed - it does not say which number.

Would anybody know what I’m doing wrong here? By the way, thank you so much for the help. I know I’m… really pretty new at this, but I’m learning. I think.

You get that error message, because you don’t have an action called “making the first bed”.

Either you haven’t defined any action at all for making beds, or you have defined it along the lines of “Making is an action applying to one thing.” or “Making a bed is an action applying to one thing.” etc. (whereas the understand statement you tried would fit most naturally with “Making the first bed is an action applying to nothing.”)

When creating a new action for something you do to or with an object, think general. You don’t know what objects a player is going to try the action on, so for the general functionality of the action you mustn’t refer to specific objects. (Instead, you add special behaviour for special objects as special cases.)

So:

Making is an action applying to one thing. Understand "make [something]" as making.
Now, that will allow a player to try making anything (“making” is of course a very annoyingly ambiguous word for interactive fiction purposes). So you have to block it in most cases.

Instead of making when the noun is not a bed: say "You can't make much anything but your bed."

(“The noun” is the thing you do something to/with.)

Hello Bobinator! Yeah, pretty much what Felix said, except he said it much more concisely.

Here, I did things a little bit differently and took them a little further.

This code should work. Essentially, there is no premade verb in the Inform library for make, because different people will want to handle that differently.

[code]A bed is a kind of supporter. A bed is enterable. A bed can be made or unmade. A bed is usually made. A bed is usually scenery.

[Note that I made the bed a supporter. Supporters are like containers except things are “on” them rather than “in” them. This is good for kitchen tables, too. Also see the “usually” statements. This is what a kind has as a default value unless told otherwise.]

Making is an action applying to one touchable thing. Understand “make [something]” as making.

Understand “straighten [bed]” as making.

[Note that, as things stand now, straighten only works as a verb if you are referring to be something which happens to be of the bed kind. That is because there is no premade straighten verb. But we are using it as a sort of alias when talking about beds.]

Carry out making:
say “That is either already made or beyond your ability.”

Instead of making the first bed:
if the first bed is unmade
begin;
now the first bed is made;
say “You put in a tremendous level of effort hoisting the covers back onto the bed, carefully smoothing them back under the pillows. Why you do this, even though you know you’ll just make a mess of them again, you aren’t entirely sure.”;
otherwise; [If the bed is made, or whatever is the opposite of the condition in the if]
say “There is no need for straightening the covers right now!”;
end if.

Instead of doing something other than examining to a bed that is not the first bed, say “I don’t think your roommate would appreciate that idea.”;

[A good way to avoid having to code making responses for every bed… if you don’t want to have to do that :slight_smile: ]

[I also changed some articles, check it out. You don’t have to keep this, just an idea of how you can use a few pronouns to describe things. Test the changed part of the code by typing “examine bed”.]

The first bed is a bed in Dormitory. Understand “my bed” as the first bed. The first bed is unmade. The first bed is proper-named. The printed name is “your bed”. The description of the first bed is “Quite possibly one of the best friends you’ve made during your time at the school. Sure, you hate the way the covers are stitched in, leaving your feet to roast under them. Sure, you hate the way one of the springs jab into your back if you lean into it a certain way. But, when it all comes down to it, it helps you get to sleep.[If bed is made]The pea-green covers are neatly straightened out.[Otherwise] The pea green covers are dangling over the edge of the bed where you left them.[END IF]”

[Below, I took the liberty of adding a second bed for demonstration purposes.]

The second bed is a bed in Dormitory. Understand “my roommate’s bed” and “roommate’s bed” as the second bed. The second bed is proper-named. The printed name is “your roommate’s bed”. The description of the second bed is “This bed has pea green covers, like yours. However, it is in much better shape, apart from the cracked headboard.”[/code]
If you have any questions, of course, feel free to ask :slight_smile:

All right, is this code correct, or am I entirely off here?

[code]
Knocking is an action applying to one touchable thing.
Understand “knock on [something]” as knocking.
Instead of knocking when the noun is not a door: say “You tap your knuckles against it, then feel kind of silly for it.”

The bathroom door is a locked and closed door. It is scenery. It is east of Dormitory and west of Bathroom.

Instead of knocking on bathroom door:
if Jernon is in Bathroom
begin;
say “‘Hang on, I’ll be done in just a minute or two!’ Jernon’s voice calls out from behind the door.”;
otherwise;
say “You get no response.”;
end if.[/code]

I think my problem is I’m having trouble understand the more ‘code’-esque parts of Inform, if that makes any sense. I’ve tried checking a few of the examples, like Emily Short’s early Inform 7 stuff, but they don’t give quite the explanation I’m looking for.

You’ll probably have to replace “knocking on bathroom door” with this:

Instead of knocking the bathroom door:

It doesn’t like the “on”… It’s because Inform code isn’t acquainted with some of the finer exceptions in the English language.

Most English verbs go like: hit ball, kick ball, throw ball, etc. There’s no preposition between the verb and the object in most cases. But “knock on” is a different case. While “on” works in the game and in quotes and stuff, it doesn’t work so well in Inform syntax.

Anyway, with that adjustment you can say “knock on door” while playing and it should work.

Or you can just rename the action to “knocking on”.

Also you need a colon rather than a semicolon after “otherwise”. I’d also just put a colon at the end of the first line of the If statement and omit the “begin” line, although I think it would work either way.

Using a semicolon after “otherwise” compiles and runs just fine for me. I take it you’ve had problems with it?

I’m having trouble with a couple of other things.

  1. I’m trying to make it so if you drop things into a toilet, you’d get the message “If you put that in there, you’d never get it back.”

Instead of putting [any touchable thing] in toilet: say "If you put that in there, you'd never get it back."
doesn’t seem to work, because when I try it, I can drop anything in there just fine.

  1. How do I make it so an action that gives a different response the second time you try it, repeats the message you got the second time you tried it?

For example:

Instead of smelling Jernon for the first time: say "He doesn't smell like much of anything, since he just had a bath. 'Is there any particular reason you're sniffing me, K'arnan?'" Instead of smelling Jernon for the second time: say "You're not THAT interested in how he smells."

EDIT: I’ve changed this to use [or] and [stopping] instead, which should hopefully do the same thing with less code.

(You may be wondering what all this interactivity is for. The answer: Not a lot, I just love adventure games that let you mess with every possible thing. That, and it’s a nice way to learn.)

  1. Instead of inserting something into toilet: say "If you put that in there, you'd never get it back."

  2. Instead of smelling Jernon: say "[one of]He doesn't smell like much of anything, since he just had a bath. 'Is there any particular reason you're sniffing me, K'arnan?'[or]You're not THAT interested in how he smells.[stopping]".
    The stopping tags and such indicate that the first time this action happens, the game should display the first message, and all times after that, the next message.

Read section 5.7 of the built-in manual for more handy shortcuts you can use :slight_smile:

EDIT: Just saw your edit, Bobinator! :slight_smile:

To add a small point to what people have said about making something, you can get Inform to assume which bed.

does the player mean making the first bed: it is likely;

This avoids disambiguation.

I agree with other people about looking through the standard actions. If I’d known about Index::Actions in the IDE, I’d have realized a lot sooner what is good stuff to implement first, and what people expect to be able to try.

Oh, and welcome!