Displaying Graphics in Inform 7

I am having no luck adding graphics to an Inform 7 project. I have added a folder Figures within the materials folder, which itself holds a file named shack.jpg, and I have ticked the Glulx option in Settings. Then I’ve entered this:

[Code begins]

The Verandah is a room.

The description is “You are standing on the verandah of a rundown shack overlooking a long-neglected and overgrown garden.”

Figure of Shack is the file “shack.jpg”.

display the Figure of Shack;

[Code ends]

On clicking Go, I get this error report:

Problem. In the sentence ‘Display the Figure of Shack’, I can’t find a verb that I know how to deal with.

Incidentally, the JPG image is 917 pixels wide x 1171. Any ideas? With thanks.

You’ll need to tell Inform when you want to display the picture. If you want to show it when the game starts:

When play begins:
    display the Figure of Shack.

Or if you want to show it with the room description:

Before looking when the location is the Verandah:
    display the Figure of Shack.

Many thanks, Juhana, for your fast response. I followed your first example but got this error report:

Problem. The text ‘When play begins:’ seems to end a paragraph with a colon. (Rule declarations can end a sentence with a colon, so maybe there’s accidentally a skipped line here?)

So I put your first two lines together, like this:


Figure of Shack is the file "shack.jpg".

When play begins: display the Figure of Shack.

The Verandah is a room.

The description is "You are standing on the verandah of a rundown  shack overlooking a long-neglected and overgrown garden."

That compiles but still no picture! Any more thoughts?

If you just copied the code from this website, it may contain spaces instead of the correct tab indentations. You may need to realign everything left, then indent it correctly, or type it out with correct tabbing manually.

Do you have shack.jpg in the materials/figures folder in your project location? You need to create this folder manually if you’re using figures.

It sounds like you read the docs, but go over Chapter 23 carefully to make sure you’ve got everything where it goes.

inform7.com/learn/man/WI_23_1.html

I have been able to show pictures just fine with similar code to what Juhana posted. However, i have not ever been able to show a picture when the game first starts (in the first room). Instead of getting a nice picture, it just shows the prompt. So, if that’s what you’re seeing, you are not alone. Someday i’ll figure out a way around it (though i’ve tried many; perhaps i need to say “xyzzy”.)