Tutorial Code doesn't work...

I’m just getting started with writing Inform 7 code, and it seems like a lot of simple things I read in the tutorial doesn’t work…

For instance, when My code is:

[code]“Pilot” by math4tots

BLANK is a room.

Let X be 5.
[/code]

I get

[code]This is the report produced by Inform 7 (build 6G60) on its most recent run through:

Problem. You wrote ‘Let X be 5’ : but I can’t find a verb here that I know how to deal with, so I am ignoring this sentence altogether.

See the manual: 2.17 > Review of Chapter 2: The Source Text

[/code]

Or even when I just try to get it to print something:

[code]“Pilot” by math4tots

BLANK is a room.

say “text”.[/code]

I get:

[code]This is the report produced by Inform 7 (build 6G60) on its most recent run through:

Problem. You wrote ‘say “text”’ : but I can’t find a verb here that I know how to deal with, so I am ignoring this sentence altogether.

See the manual: 2.17 > Review of Chapter 2: The Source Text

[/code]

I’d appreciate any help to get this to work. Thanks.

is basically saying that statements like let X be 5 or say “text” can’t be written down by themselves, but need to be put inside something like a rule, phrase, activity, etcetera. For example,

When play begins:
    let X be 5;
    say "[X]".

(note that if you copy that directly to the IDE, you’ll probably have to replace the spacing of the indented lines with TABs).

It’s confusing for people new to I7 and never really explained as far as I can see in the docs, but you’ll quickly get the hang of it I think.

Well, chapter 2 of the documentation might help here – especially 2.2.

The way Inform works is that every turn it reads a command and has rules to do things in response to that command. In order to tell Inform to do something, you have to wrap it in a rule telling it when to do it. So

Say "text."

doesn’t do anything, because it doesn’t have anything saying when to say “text.” You can have something like

When play begins: say "text."

which will print it at the very beginning when the game runs, or

Every turn: say "text."

which will print it every single turn, or

Instead of jumping: say "text."

which will print it whenever the player tries to jump (by entering the command “JUMP”).

So, keep reading the manual to see how this works (you might want to skip sections 2.5 through 2.15 or so on your first run through, as they involve stuff you won’t need to use until after you’ve got this down.

When you’re writing an Inform 7 program, you’re writing two kinds of statements. (1) Statements that describe the initial situation of the game world. (2) Rules. Rules govern how the world will change based on the player’s input, as well as some other things.

You can write things like this:

The church is a room. A fruit is a kind of thing. An apple is a kind of fruit. In the church are two apples. The description of an apple is "Nice and green.".
All of those statements describe the initial situation of the world.

Everything else must be a rule, of which Matt gave some good examples.

It sounds like you’re coming from a procedural programming perspective, where you expect to start by writing a program that prints “hello world” and exits. I7 is not a very procedural language - it has an event loop built in, as others have mentioned, and most of what you’re doing is writing what other languages would call “callbacks.” It can be hard to get your head around the principles, but I’ve found it very rewarding.

I would perhaps argue with Victor to say that phrases are not rules, but they do behave in much the same way - you write them without necessarily knowing when they will execute. They are more like functions in other programming languages than rules are, though, in the sense that they are invoked directly rather than through a rulebook.

Have you seen Ron Newcomb’s “Inform 7 for Programmers?”

ifwiki.org/index.php/Inform_ … rogrammers

Hopefully someone can let me know if there’s a more recent version - I think there’s a nice PDF somewhere.

I sometimes wonder if it wouldn’t be easier for new Inform programmers if bare phrases were implicitly treated as “when play begins” rules, or if that would just lead to more confusion.

In cases like that, I think the best approach is a suggestion in the compiler error.