Basic help with Inform 7

Completely new to creating IF, so really sorry if these questions are painfully obvious. I will probably refer back to this thread when the included documentation fails me, or if I fail to understand the documentation.

Ok, some basic questions:

I can describe a room and the things in it. However, when I run the story, it prints my description and then still proceeds to list every visible object and its properties after. How do I have it not list these objects, and rather have any change in the state of the objects (stuff being opened/closed/taken) be reflected by altering the description?

Eg.

Kirsty's room is a room.  The table is in Kirsty's room. The table is a supporter. On the table is a handbag. The handbag is closed. The handbag is an openable container.  Kirsty's keys are inside the handbag. "[if open]There is an open handbag on the table, containing keys.[otherwise] There is a closed handbag on the table."

Just prints: Kirsty’s room
You can see a table (on which is a handbag (closed)) here.

I just don’t quite grasp the code yet, as you can see (I have VERY little experience in coding)

Not quite sure the exact syntax of creating rules. The manual has some examples, but I don’t know the limits of what it can understand and the bug-reporter keeps mentioning incorrect use of punctuation which looks about right to me.

Probably to be updated soon with more questions. Thanks in advance for your help.

If you want an object not to be mentioned in the room description, add the sentence “It is undescribed.”.

Well, the manual says “undescribed” is a last resort; usually, if you don’t want something to be mentioned after the room description, and it’s not supposed to be takeable either (which is probably the case for your table), you declare it as scenery.

Here’s the relevant paragraph from section 3.24 of the manual:

The rules that govern what is printed when you LOOK in a room (which you do automatically when you enter one) is actually pretty complex. Several different activities are involved. (Writing a paragraph about; Listing nondescript items of something; Printing the locale description of something; Choosing notable locale objects for something; Printing a locale paragraph about and Printing room description details of something: see the Activities chapter of the documentation.)

If you want Inform never to print that last list of things you can add

Rule for listing nondescript items: do nothing.

There are two other problems with the posted code.

Firstly, Inform does not understand that the quoted text at the end of the posted code is meant as a room description. Instead it thinks that this piece of quoted text is the so-called “initial appearance” of Kirsty’s keys (since it follows directly after the creation of the keys in the source text). Either write The description of Kirsty's room is "[if the handbag is open]There is an open [handbag] on [the table], containing [keys].[otherwise] There is a closed [handbag] on [the table]." or put the quoted text immediately after the creation of the room. Kirsty's room is a room. "[if the handbag is open]There is an open [handbag] on [the table], containing [keys].[otherwise] There is a closed [handbag] on [the table]."

Secondly, Inform does not understand that the “[if open]”-condition refers to the handbag. (I suppose it takes it to mean “if is open”.) Write "[if the handbag is open]" instead.

Thanks for the help so far guys.

Next question:

I have an object I want to only be picked up in a certain container.

So far, I have the rule Instead of taking [an object], say "I'm not touching that with my hands!".

This works fine, but I can’t work out how to transfer an object to its specified container without first been taken. (the container is in the possession of the player)

You can “move (thing) to (container)”.
See chapter 8.7, “Moving Things”.

Instead of taking [object]: try moving [object] into a [container].

turns out ‘this is not an action I recognise’
Am I phrasing this correctly?

Basically, I need something that says ‘When the player tries to take [object] (or put [object] in [container]), if the player is carrying [container], move [object] to [container], otherwise say “arbitrary failure message”’

“Move” isn’t an action that the player can do, which is why “try moving” doesn’t work – it’s a phrase that you can use in Inform 7 to, well, move the object to wherever you want. So something like this (untested):

Instead of taking the slime: if the player carries the jar: say "You scoop the slime up with the jar."; move the slime to the jar; otherwise: say "You're not picking that up with your hands!"

“Now the slime is in the jar” should have the same effect (right?)

EDIT: Oh, and bracketed tokens only work inside quotation marks. Outisde quotations, any text that’s in brackets is treated as a comment, which is to say ignored completely. Where you have “[object]” you will usually want to say “the noun” (the code I gave above should also work if you said “move the noun to the jar”); “move the noun to a container” wouldn’t work, though, because I7 wouldn’t know which container to move it to. If you want to let the player scoop the slime up with any container things will get a little more complicated, but from your post I figured you had one particular container in mind.

Moving is not an action, but a part of the Inform 7 language. (So you cannot “try moving”, because you can only “try” actions.) You will want some variant of this:

[code]Instead of taking the cigar:
unless the player carries the plastic bag:
say “Touching that would destroy the evidence!”.

Instead of taking the cigar:
if the cigar is in the plastic bag:
say “It is already where you want it.”.

Instead of taking the cigar:
move cigar to plastic bag;
say “You carefully put the cigar in the plastic bag.” instead.[/code]

That’s great! Thanks! And the objects were mould and a bottle. I don’t know why I shied from disclosing that info.

Wait, can you do that in three separate “Instead” rules? Won’t the first one fire and block the other two? (Nice catch on the last case, anyway.)

Matt, you are right, and I was not thinking. (This is one of the reasons I prefer Check, Carry out, Report to Before, Instead, After.) The right code would be this:

[code]Instead of taking the cigar when the player does not carry the plastic bag:
say “Touching that would destroy the evidence!”.

Instead of taking the cigar when the cigar is in the plastic bag:
say “It is already where you want it.”.

Instead of taking the cigar:
move cigar to plastic bag;
say “You carefully put the cigar in the plastic bag.” instead.[/code]

Ok, so carrying on from my first question. I’ve used the ‘rule for listing nondescript items: do nothing’ command. However, what if I want things to be listed normally if something has moved?

So for instance: Kirsty's room is a room. "In your room, there is a [table], on which is [a list of things on the table]. You can also see a wooden door to the east, leading to a corridor." The table is in Kirsty's room. The table is scenery. The table is a supporter. On the table is a handbag. The handbag is closed. The handbag is an openable container. Kirsty's keys are inside the handbag.

Gives ‘In your room, there is a table, on which is a handbag. You can also see a wooden door to the east, leading to a corridor.’

What if I want the handbag to then be described by the engine if the player has moved the handbag to the floor? So, take handbag, drop handbag gives:

'In your room, there is a table, on which is nothing. You can also see a wooden door to the east, leading to a corridor.

You can see a handbag (closed) here.’

Sorry about the questions and the frightfully boring coding exercise describing my girlfriend’s flat.

Nothing wrong with coding up your (or your girlfriend’s) apartment, so long as you don’t release the game!

As Felix said, “Rule for listing nondescript items: do nothing.” means that you will never print up the “You can see…” message describing things in the room. That’s a pretty drastic step, which you probably don’t want to do unless you’ve got some sort of blanket rule that lists everything in the room anyway.

In this case, the room description has already told us about the table and everything on it, so we don’t want that to appear after the room description text. The table is taken care of, because it’s scenery, but we have to get rid of the “On the table…” text too. If you run the game in the IDE, type “rules,” and then “look,” you’ll see that that text is produced by the “describe what’s on scenery supporters in room descriptions rule.” This is kind of annoying, because it means we have to go into the Standard Rules, find that rule, and replace it with a new rule of our own devising that doesn’t print the contents of the table. (As the manual says, this rule is somewhat controversial.)

So we add this giant wodge of code:

[code]For printing a locale paragraph about a thing (called the item)
(this is the describe what’s on scenery supporters in room descriptions except the table rule):
if the item is not undescribed and the item is scenery and
the item does not enclose the player and the item is not the table:
set pronouns from the item;
if a locale-supportable thing is on the item:
repeat with possibility running through things on the item:
now the possibility is marked for listing;
if the possibility is mentioned:
now the possibility is not marked for listing;
increase the locale paragraph count by 1;
say "On [the item] ";
list the contents of the item, as a sentence, including contents,
giving brief inventory information, tersely, not listing
concealed items, prefacing with is/are, listing marked items only;
say “.[paragraph break]”;
continue the activity.

The describe what’s on scenery supporters in room descriptions except the table rule is listed instead of the describe what’s on scenery supporters in room descriptions rule in the for printing a locale paragraph about rulebook.
[/code]

Which may seem intimidating, but all I did is go into the Standard Rules, copy out “the describe what’s on scenery supporters in room descriptions rule,” stick “and the item is not the table” in, give the rule a new name, and add the last sentence about how to put our rule in for the old rule. (Which took a little banging my head against the wall to figure out exactly what the name of the rulebook was.)

[UPDATE: I forgot to say, take out “Rule for listing nondescript items: do nothing.”]

If we wanted to do this with more than one supporter in the game, then the thing to do would be to give supporters a property that determined whether or not to list their contents after the room description, and test for that instead of writing “if the item is not the table.” (In fact, I think it might be kind of nice if the standard rules had a hook for that instead of making us write a new one.)

One more thing: If you pick up the handbag and look, you’ll get “In your room is a table, on which is nothing.” That’s not appealing. We can take care of this by setting a condition on the description, so if nothing is on the table it doesn’t print “on which is” at all:

"In your room, there is a [table][if something is on the table], on which is [a list of things on the table][end if]. You can also see a wooden door to the east, leading to a corridor."

(Another issue is that it says “is” even if there’s more than one thing on the table, or one thing with a plural name like Kirsty’s keys. That’s something you can take care of with Emily Short’s Plurality extension – but you’ve got enough on your plate now!)

Ok, trying to wrap my head around that!

And work out the correct indentations, since copypasting the code just replaces the indentations with spaces…

I will probably be reading this several times before I have any idea what it means.

The easy solution: Download and install the Mentioned in Room Description extension and include it. It suppresses the extra paragraph automatically if the thing is already mentioned in the room description and shows it normally otherwise.

Juhana thank you that’s great! Works just as I want :slight_smile:

Matt w, I will still be re-reading to understand better, as I can see that knowing the code well is important for other applications.

You can work around this – from another user:

Also, remember to hit cancel after you’re done cutting and pasting or you might send a blank post by mistake.

Instead of putting something in container:

is not understood as an action. What does inform understand as the participle of the player action ‘put X in Y’?

I believe the technical name of the action is “inserting it into.” Thus, you would say “Instead of inserting something into a container . . .”

The “actions” tab under the Index pane gives a list of all actions and the commands that invoke them. Thus, if you run into this type of situation, you could look up the “put” command and see that it refers to the “inserting it into” action.

Robert Rothman