Images And Specific locations/objects

I must be overlooking something simple…

I am just trying to get images to display when a player enters each room and trying to make a map the player can carry.

I have all the images in fine I am just struggling to get the code right. At the minute my map is displayed every time the player ‘looks’ but my room images don’t appear.

Before looking when the player is enclosing the Map:
	display the Figure of Map

Ideally this wouldn’t happen with the map either…only when the player specifically looks at it.

Any help would be very welcome

Thanks

Hi! Which program are you using? :slight_smile:

Inform 10, sorry.

Before looking when the location is Barn:
	display the Figure of Barn;
Instead of examining the Map:
    display the Figure of Map;

EXAMINE covers synonyms “examine map/look at map/read map”.

More complicated: (I haven’t tested, but this should be possible)

A room has some text called image-name.

Barn is a room "It's dusty in here." The image-name of Barn is "Barn".

Before looking:
    if the image-name of the location is not "":
        display the figure of image-name of the location.

It might need to be

The image-name of Barn is "figure of Barn".

Before looking:
    if the image-name of the location is not "":
        display the image-name of the location.

(Hopefully the @mad-scientists will swoop in and correct me!)

1 Like

Thanks for your reply.

The game keeps freezing when it’s trying to load an image. I tried making it smaller (100kb) but still, every time it tries to load the cursor disapears and I can’t do anything.

It hasn’t crashed and I’m able to click go/replay

Any idea?

Thanks again

You said it worked with the map?

(Don’t try my second two suggestions as I may have worded them wrong.)

(Also don’t use my exact code where I’ve made up “Barn” unless you have an actual figure of Barn…)

The image size shouldn’t be the problem. Take out the code you added piece by piece until it compiles again then share your code again for this part.

It sounds like you made it work with one image for every room (the map) so try making just one room image work and the map work separately based on the command you give it - verify you can see a room picture when you LOOK and a different map picture when you EXAMINE MAP.

2 Likes

Emily Short has an extension called ‘Location Images’ that works just fine. You can type stuff like Figure of 1_lake is the file "1_lake.jpg and The room-illustration of Lake is figure of 1_lake.

And if you want to show the map at any time, you can say:

now currently shown picture is the room-illustration of the location;
follow the current graphics drawing rule.

If you look at the code for the extension, it’s really small, and just uses the extensions Simple Graphical Window, which might work better for you.

Here’s a sample game using this technique:
https://media.textadventures.co.uk/games/q64Wf_To7k6SQ6Jj6k8NZA/Release/index.html

(you may need to download an older version of Glulx Entry Points to get it to work).

3 Likes

A figure name is really an enumerated value (like colour is a kind of value. Some colours are red, green, blue), stored internally as an integer that is an index to the separately-maintained list of filenames declared by Figure of ... is the file "...".

So when we write

display the figure of Daffodils

‘figure of Daffodils’ is internally an integer index number, and we are asking Inform to use that index number to look up the filename that was declared as associated to that integer index number.

So we can’t use a text value stored in a property to look up the filename. The property of the room has to be of figure name kind i.e. a member of the figure names enumeration, not text kind.

A room has a figure name called illustration.
Before looking:
	unless the illustration of the location is Figure of cover: [the default value for figure names]
		display the illustration of the location.

e.g.

The Undercroft is a dark room with description “Barrels of gunpowder are stacked against every wall, poorly concealed behind palisades of brushwood.” and illustration Figure of Undercroft. Figure of Undercroft is the file “Undercroft.jpg”.

4 Likes

Thank you for the clarification. I figured there would be a way to do this and it makes more sense to associate a figure-name directly to an object or a room than it does to change the figure name to text and back again!

1 Like

Thanks for the replies everyone. There’s a lot to go through here!

I will explore these suggestions this evening and come back to you all.

Thanks. I really appreciate the input

Yes the map displays fine using the code you suggested, If i type ‘look’ or ‘examine’ map it come up.

When I go in to the only room with an image currently and type look that’s when it freezes.

Can you show us (paste into the forum in a code block) the section where you define the room image figure/file and the rule to display it?

I believe when you move to a new room there is an inherent invisible LOOK command that displays the room description, and ideally your image. Do you see the image when you enter and then does it crash on the manual LOOK command? Or are you getting no image and a crash on manual LOOK?

1 Like

Just going through what the mad scientists added…will report back shortly

Ok so i tried this

A room has a figure name called illustration.
Before looking:
	unless the illustration of the location is Figure of cover: 
		display the illustration of the location.

and this

Class 1 is a room with description “The room smells faintly of rotten eggs, it slowly gets stronger as each student unscrews the lids of their, very old, wet on wet paints. On the blackboared is an elaborate and beautiful drawing of their current main lesson.” and illustration Figure of Isabella. Figure of Isabella is the file “class 1.png”.

bur I’m getting the same issue…as soon as i ‘look’ the cursor disappears!

You need to define your figures first in the source code before you call them in a rule. I always define all figures and sounds first all at once.

You also usually need to split up declarations - they all need their own subject: “the sled is a vehicle and cold” won’t work. “The sled is a vehicle. It is cold” or “the sled is a vehicle. The sled is cold” should work.

Figure of Isabella is the file “class 1.png”.

Class 1 is a room with description “The room smells faintly of rotten eggs, it slowly gets stronger as each student unscrews the lids of their, very old, wet on wet paints. On the blackboared is an elaborate and beautiful drawing of their current main lesson.”

The illustration of Class 1 is Figure of Isabella.

Well, I suppose you sort-of could (although this is looking up the corresponding figure name, not the filename directly):

A room has a text called picture.
Before looking:
	unless the picture of the location is "": 
		repeat with f running through figure names:
			if "[f]" is the picture of the location:
				display f;
				break;

but you probably don’t want to.

You can write The sled is a cold vehicle.

You can also use ‘and’ or commas to list named properties of an object after ‘with’ or ‘having’. Adjectives derived from unnamed properties can be listed before the kind name (as also shown in the sled example):

Class 1 is a dark singular-named unvisited room with description “The room smells faintly of rotten eggs, it slowly gets stronger as each student unscrews the lids of their, very old, wet on wet paints. On the blackboard is an elaborate and beautiful drawing of their current main lesson.”, printed name “Classroom One” and illustration Figure of Isabella.

1 Like

Thanks everyone.

So I tried this just now:

Class 1 has a figure name called illustration.
Before looking:
	unless the illustration of the location is Figure of cover: 
		display the illustration of the location.


Figure of Isabella is the file “class 1.png”.

Class 1 is a room with description “The room smells faintly of rotten eggs, it slowly gets stronger as each student unscrews the lids of their, very old, wet on wet paints. On the blackboard is an elaborate and beautiful drawing of their current main lesson.”

The illustration of Class 1 is Figure of Isabella.

But I’m still getting the same issue. - Cursor disappears when I type look in class 1.

Any suggestions?

Thanks

Figure of Isabella is the file “class 1.png”.
Figure of Digestive System is the file "spaghetti.jpg".
A room has a figure name called illustration.

Before looking:
	unless the illustration of the location is Figure of cover: 
		display the illustration of the location.

Class 1 is a room. “The room smells faintly of rotten eggs, it slowly gets stronger as each student unscrews the lids of their, very old, wet on wet paints. On the blackboard is an elaborate and beautiful drawing of their current main lesson.” The illustration of Class 1 is Figure of Isabella.

Class 2 is a room. "This is where health class takes place. It holds many traumatic memories." The illustration of Class 2 is Figure of Digestive System.

You need to literally write, word for word,

A room has a figure name called illustration.

to set up every room with a property called illustration to hold figure names.

Then, for every room that has a picture file:

The illustration of <name of room> is Figure of ... 

or

<name of room> is a room with illustration Figure of ...