Is it possible to print the description of a room specified by the player?

Okay, for context. I’m working on an ghost story which uses photography as part of it’s main mechanic. At any location the player can take a photograph; this is indicated by setting an attribute attached to each room. The player can then examine the photograph taken, and in some locations the photo may reveal something that normally can’t be seen.

I’m using say phrases to save me typing out the description of every location twice, once for the location and once for the photo. A truth state passed to the say phrase allows me to determine whether the phrase is being used as the main room description, or the photo taken of the location.

This currently works perfectly if the player is in the same location as the photograph they are looking at.

However I’ve recently added the ability to look at all the photographs. This runs through all the rooms looking for the attribute indicating that a photo has been taken there and lists out those locations.

For example:

>Look at all photographs

You activate the preview function of your camera and quickly flip through the photographs you have taken since you arrived. You have photographs of the porch, the foyer, the dining room and the eastern hallway.

What I would like to do is to be able to examine the photograph taken of any room without having to find your way back to that room using a command something like..

>Look at photograph of the foyer.

Using the preview function of the camera you quickly call up the photograph you took.

Dust and cobwebs cover every surface. A wide staircase sweeps upwards from the centre of the room to a landing where a spectral figure mournfully gazes at the portrait of a young soldier.

>Look at photograph of the graveyard

Using the preview function of the camera you fail to find any such photograph.

Is this even possible? I would need to be able to confirm that the name of the photograph is actually a location and then be able to check its attributes and print its descriptionif it has been photographed. So if the player tries to look at a photograph of a location that exists but hasn’t been photographed, or tries to look at a photograph of something that isn’t a room or doesn’t even exist in the game, I can print out that no photo can be found.

e.g.

Look at photograph of the master bedroom (when the master bedroom is a room but hasn’t been photographed)

Look at photograph of the battery pack (an object that exists in the game but only locations can be photographed)

Look at photograph of the hairy goat (no such object exists in the game, this is just a piece of text)

I need to be able to respond to each of them and report back that no such photo can be found.

I’ve tried to explain this as best as I can, but if I’m not making sense let me know and I’ll try to clear things up.

2 Likes

I’d probably just give a photograph (which I presume is a kind) a room that’s set by the location where the player was when it was taken - then you can just say the description of the variable.

You can even do something fancy like this:

Depiction relates various photographs to one room (called the referent).
Understand "of [something related by depiction]" as a photograph.
4 Likes

Would this work if there were many photographs. Essentially there can be as many photographs as there are locations in the story. Most photographs will be the same as the location where they were first taken as nothing special is associated with them. Some photographs capture the state of the original location before it is changed subtly in some way during the game, Some photograph will contain otherworldy additions to the room, such as a misty spirit, lights, phantom objects, etc, No location can have more than one photograph though.

I guess what I’m trying to say is, can I have the player type in the name of a location which will effectively become a noun, test it to see whether it is a room in the game, and treat the result as a room in order to re-print it’s description.

A similar idea would be having a crystal ball in a tower through which a player could spy on any other room by typing commands in such as “Spy on the king’s chamber. Spy on the drawbridge.” etc.

Sadly I’ve never managed to make sense of relations in inform 7 either from the documentation, in built help, or my other reference which is my copy of Aaron A. Reed’s book where he explains it whilst writing the story Sand Dancer; it all just went over my head. If anyone can point me to something that explains relations in layman’s terms (read - for idiots like me), I can see if I can get this method to work for me.

Do you want to track the photographs as individual objects (each tracking which room it was taken in), or do you want it to be more abstract, and just track whether each room was photographed (without worrying about players picking up or dropping individual photographs)?

1 Like

What I’m doing is just tracking whether a location has been photographed. The way I’m doing this at present is:

A room can be photographed. A room is not photographed.

I can then take a photograph of the room at any point assuming I’m carrying the camera

Photographing is an action applying to nothing.
Understand “Take photo/photograph” as photographing.
Before photographing:
if the location of the player is photographed:
say “Thumbing through the photographs stored on the camera you realise that you’ve already taken a photograph here.” instead.
Instead of photographing:
now the location of the player is photographed;
say “You carefully frame your shot and trigger the shutter. The photograph is now stored on the camera.”

To save me doubling up on the text whenever examining the actual room or the photograph I’ve created a say phrase to handle the locations.

To say describe_location(show_photo - a truth state):
if the location is the main hall:
say “A grand staircase climbs from the centre of the room[if show_photo is true]. A strange mist appears to cascade down from the upper floor flowing over each step like a slow waterfall[end if].”;
otherwise if the location is …. etc.

The room is then created

Main Hall is a room. “[describe_location false]”.

If I’m in stood in the main hall and I want to look at the photograph that I’d previously taken

Examining_photograph is an action applying to nothing.
Understand “Examine photo/photograph” as examining_photograph.
Before examining_photograph:
if the location is not photographed:
say “You don’t appear to have taken a photograph here yet.” instead.
Instead of examining_photograph:
say “You thumb through the preview photos on the camera until you find this place and look at it.”
say “[describe_location true]”.

If I want to see what where all the photographs are stored on the camera were taken.

Examining_all_photographs is an action applying to nothing.
Understand “Examine photographs/photos” as examining_all_photographs.
Instead of examining_all_photographs:
let pcount be a number;
now pcount is 0;
repeat with loc running through all rooms:
if the loc is photographed:
increase pcount by 1;
if pcount is 0:
say “Activating the preview mode on the camera you are greeted with the message [bold type]No Images[roman type].”;
otherwise if pcount is 1:
say "Activating the preview mode on the camera shows that you have only taken one photograph so far, and that is of ";
repeat with loc running through all rooms:
if the loc is photographed:
say “[the loc].”;
otherwise:
say "Activating the preview mode on the camera shows that you have taken photographs of ";
let firstloc be a truth state;
now firstloc is true;
repeat with loc running through all rooms:
if the loc is photographed:
if firstloc is false:
if pcount is 1:
say " and ";
otherwise:
say ", ";
say “[the loc]”;
if pcount is 1:
say “.”;
now firstloc is false;
decrease pcount by 1.

I apologise if my indents are wrong, the copy and paste from my code didn’t carry them through so I’ve had to do it manually.

There are probably better ways to do what I’ve done, this is only my second foray into Inform 7 code so I’m still learning. I didn’t really want to create a photograph object for every photograph that can be taken as they are not physical things, just images stored on the camera.

What I’m hoping to achieve is for the player to enter the command

Examine photograph of the main hall

From anywhere in the game. This would help if, for examine, the photograph taken in the main hall helps with a puzzle set in the cellar without the player keep having to travel backwards and forwards between the two locations every time just to view the photo.

I’m probably being a bit too ambitious.

If you don’t mind creating an actual photograph object which corresponds to each room, you can do something like this:

Lab is a room. "A cluttered lab."
Closet is south of lab. "A cramped closet."
Office is east of lab. "A boring office."

The player carries a camera.

A photograph is a kind of thing.

Photography relates one room (called the subject) to one photograph.
The verb to depict means the reversed photography relation.

Every room is depicted by a photograph.
Understand "of [something related by reversed photography]" as a photograph.
The printed name of a photograph is always "photograph of [the subject]".

Carry out examining a photograph: say "[description of the subject of the noun]"; rule succeeds.

Photographing is an action applying to nothing. 

Understand "photograph" as photographing.

Carry out photographing: say "Click!"; now a random photograph which depicts the location is part of the camera.

Test me with "x photograph / photograph / x photograph / s / photograph / x photograph of lab / x photograph of closet"

Be aware that disambiguation doesn’t work properly with the above code; if you type “X PHOTOGRAPH” when you’ve taken more than one, it will pick one at random rather than asking which do you mean. Hopefully someone else can clarify why that is.

3 Likes

Hi Colin, welcome!

A couple of things:

If you use three backticks, i.e. ``` on its own line before and again after the entire block of code, you should have better luck cutting and pasting with preserved indents. It will also allow others to click on the clipboard icon that appears when hovering the mouse over the top right of your code so they can post it into their IDE (see my code below).

The easiest method when using the markdown editor is to use the Preformatted text button, which looks like </> . Both sets of backticks will appear in your editor window like this:
```
type or paste code here
```

As for your question, if you haven’t already, you should look at ex. 322 “Claims Adjustment” in the Recipe Book of the Inform docs. It is similar in principle to Adam’s implementation, but deals with individual objects rather than rooms.

Also, in my experience, if I find myself writing big loops with counters and special cases, there is usually a cleaner, more-Informy if you will, method. For example, your “Instead of examining_all_photographs” rule could be implemented more succinctly:

Carry out examining_all_photographs:
	let pcount be the number of photographed rooms;
	if pcount is 0:
		say “Activating the preview mode on the camera you are greeted with the message [bold type]No Images[roman type].”;
	otherwise:
		say "Activating the preview mode on the camera shows that you have [if pcount is 1]only taken one photograph so far, and that is of [otherwise]taken photographs of [end if][the list of photographed rooms].".

Note that I’ve changed it from an “instead” to a “carry out” rule, which is more appropriate in this case. Also, the text substitution “the list of …” already handles commas and the word “and” for you.

1 Like

BadParser: Thanks for putting me straight, I appreciate it.

Adam: Appreciate the help, I’ll give it a try over the next few days.

1 Like

This comes down to whether or not the parser sees photographs as “identical” or not. For this purpose, identical objects are those that cannot be distinguished from one another via player command input. If a group of objects are considered identical and equally likely to be the object meant, then the parser will just pick one.

Although you’ve provided an Understand statement to let photographs be referenced by the rooms that they depict, this type of relation-based understanding is not taken into account by the code that determines whether two objects are identical.

Zed once demonstrated an effective workaround in which the objects are given a text property, and that text property is understood (i.e. Understand ... as describing ... or Understand ... as referring to ...).

Since you’re using an assembly in your example, however, it’s probably easiest to just take advantage of the ability to add automatic naming:

Every room is depicted by a photograph (called photo of it).
2 Likes

This is likely not helpful for anything, but I remember having the same roadblocks in a game that featured a digital camera with a screen taking pictures of rooms and things and being a potential light source in dark rooms and operating on rechargeable batteries and creating optional sounds which was a more of a nightmare than the actual plot of the game…

Applicable source text - lengthy and potentially unworkable for anything else!
Volume 10 - Photography

a camera is a kind of thing.  Understand "camera" as a camera.

photographing is an action applying to one visible thing.

Check photographing:
	if the player does not have a camera:
		say "Since you don't have a photographic memory, you'll need a camera to record the moment." instead.

Understand "photograph [something]" and "photo [something]" and "shoot [something]" and "snap [something]" and "take picture/pic/photo/image/photograph of [something]" and "shoot photo/picture/pic/image/photograph of [something]" and "snap photo/picture/pic/image/photograph of [something]" as photographing.

Understand "p" as photographing generally.

Understand "p [something]" as photographing.

First check photographing:
	if the noun is a room:
		try photographing generally instead.

Understand "photograph [a backdrop]" and "shoot [a backdrop]" and "snap [a backdrop]" and "take picture/pic/photo/image/photograph of [a backdrop]" and "shoot photo/picture/pic/image/photograph of [a backdrop]" and "snap photo/picture/pic/image/photograph of [a backdrop]" as photographing.

Photographing generally is an action applying to nothing.

Check photographing generally:
	if the player does not have a camera:
		say "Since you don't have a photographic memory, you'll need a camera to record the moment." instead.

Understand "photograph" and "photo" and "pic" and "take picture/pic/photo/photograph/image" and "shoot photo/picture/pic/image/photograph" and "snap photo/picture/pic/image/photograph" and "use flash" and "flash" as photographing generally.

Carry out photographing:
	if soundyes is true:
		play sound of camera on midground.
		
Carry out photographing:
	now the noun is seen.
		
Carry out photographing generally:
	if soundyes is true:
		play sound of camera on midground.

Report photographing:
	say "You take a photo of [the noun].";
	
General roomsnapping is an action applying to nothing and requiring light.  
	
Understand "photograph my/-- room/chamber/space/here/location/surroundings/environment" and "photograph the/this room/chamber/space/location/surroundings/environment" and "photo my/-- room/chamber/space/here/location/surroundings/environment" and "photo the/this room/chamber/space/location/surroundings/environment" and "shoot my/-- room/chamber/space/here/location/surroundings/environment" and "shoot the/this room/chamber/space/location/surroundings/environment" and "snap my/-- room/chamber/space/here/location/surroundings/environment" and "snap the/this room/chamber/space/location/surroundings/environment" and "take a/-- picture/pic/photo/image/photograph of my/the/-- room/chamber/space/here/location/surroundings/environment" and "take a/-- picture/pic/photo/image/photograph of the/this room/chamber/space/location/surroundings/environment" and "shoot a/-- photo/picture/pic/image/photograph of my/the/-- room/chamber/space/here/location/surroundings/environment" and "shoot a/-- photo/picture/pic/image/photograph of the/this room/chamber/space/location/surroundings/environment" and "snap a/-- photo/picture/pic/image/photograph of my/the/-- room/chamber/space/here/location/surroundings/environment" and "snap a/-- photo/picture/pic/image/photograph of the/this room/chamber/space/location/surroundings/environment" as general roomsnapping.
	
Instead of general roomsnapping:
	try photographing generally.
	
Report photographing generally:
	say "You take an overview photo of the location."
	
A thing can be captured.  A room can be captured.  A backdrop can be captured.

Carry out photographing:
	now the noun is captured.
	
Carry out photographing generally:
	now the location of the player is captured.
	
To review photos:
	if a room is captured:
		say "You've gotten [if more than one room is captured]wide angles of[otherwise]a wide angle of[end if] [the list of the captured rooms].";
	if a thing is captured:
		say "You've gotten [if more than one thing is captured]pictures of[otherwise]a picture of[end if] [a list of captured things].";
	if a backdrop is captured:
		say "You've got [if more than one backdrop is captured]artistic shots of[otherwise]an artistic shot of[end if] [a list of captured backdrops]."
				
After taking inventory:
	if the player has a camera:
		review photos.
		
Does the player mean taking something in the equipment bag:
	it is very unlikely.
	
Volume 11 - Darkness/Flashing

room description body text rule response (A) is "[one of]Inky[or]Pitch black[or]Utter[or]Complete[or]Overwhelming[at random] darkness [one of]presses in around you[or]surrounds you completely[or]obscures nearly everything[or]disorients your sense of direction[or]obliterates your perception of the size of the room[or]seeps in at every side[or]slithers around you[or]brings a chill to your skin[or]winds you in a gauzy shroud[or]inspires both claustrophobia and acrophobia simultaneously as you could just as well be shut up in a tomb as floating in space[as decreasingly likely outcomes].".

The last seen object is a thing that varies.  The last seen object is yourself.

Carry out going:
	now the last seen object is empty space.

After deciding the scope of the player when in darkness:
	if the last seen object is not nothing:
		place the last seen object in scope;
	if the location encloses an easydoor:
		repeat with ED running through easydoors in the location:
			place ED in scope;
	if the location encloses a lamp:
		repeat with L running through lamps in the location:
			if we have switched on L:
				place L in scope;
	if the location encloses a light switch:
		repeat with S running through light switches in the location:
			if we have switched on S:
				place S in scope.
		
Visibility when taking the last seen object:
	There is sufficient light.
	
Visibility when examining the last seen object:
	There is sufficient light.
	
Visibility when opening the last seen object:
	there is sufficient light.
	
Visibility when closing the last seen object:
	There is sufficient light.

Visibility when switching on something:
	There is sufficient light.
	
Instead of examining something when in darkness:
	if the noun is touchable:
		say "You feel around for [the noun] and finally find it in the dark.  It's [the noun] or at least something [noun]-shaped.";
	otherwise:
		say "You saw it when the camera flashed, but now you can't seem to find it anywhere.";
	rule succeeds.
	
Flashing is an action applying to nothing.  



Definition: a thing (called T) is external:
	if T is the player:
		decide no;
	if T is enclosed by the player:
		decide no;
	if T is enclosed by the location of the player:
		decide yes;
	if T is the fusebox:
		decide yes;
	if T is the circuit breaker:
		decide yes;
	if T is a feeler:
		decide no;
	if T is a backdrop:
		decide no;
	decide no.
	
Check flashing:
	if the player does not have a camera:
		say "You wish you had your camera so you could.";
		stop the action.
		
Check flashing:
	if compartment does not contain a battery:
		say "Nothing happens.  You realize from the lightness of the camera that there's probably no battery installed.";
		stop the action.
		
Check flashing:
	if compartment does not contain a charged battery:
		say "You press the button.  There's enough charge to make an unhelpful beeping sound, but not enough to power the flash.";
		if soundyes is true:
			play sound of CameraBeep on Midground;
		stop the action.

A thing can be search-preferred.  A lamp is search-preferred.   A light switch is search-preferred.

Glimpsed is a thing that varies.



Carry out flashing:
	now glimpsed is a random thing in the location;
	if a phantasm is in the location:
		if a random chance of 1 in 4 succeeds:
			now glimpsed is a random phantasm in the location;
		otherwise:
			if a search-preferred thing is in the location:
				if a random chance of 1 in 2 succeeds:
					if the last seen object is not search-preferred:
						now glimpsed is a random search-preferred thing in the location;
					otherwise:
						now glimpsed is a random external thing in the location;
				otherwise:
					now glimpsed is a random external thing in the location;
	otherwise:
		if a search-preferred thing is in the location:
			if a random chance of 1 in 3 succeeds:
				if the last seen object is not search-preferred:
					now glimpsed is a random search-preferred thing in the location;
				otherwise:
					now glimpsed is a random external thing in the location;
			otherwise:
				now glimpsed is a random external thing in the location;
	if glimpsed is nothing or glimpsed is yourself or glimpsed is a feeler:
		now glimpsed is empty space;
		rule succeeds;
	now the last seen object is glimpsed.
	
Carry out flashing:
	if soundyes is true:
		play sound of Camera on Midground.
		
Carry out flashing:
	decrease the power of a random battery in compartment by a random number between 0 and 2.
		
Report flashing:
	[if a phantasm is enclosed by the location:
		if a random chance of 1 in 3 succeeds:
			now the last seen object is a random phantasm in the location;
	if the last seen object is nothing:
		now the last seen object is empty space;]
	say "The camera flash reveals, for an instant, [if last seen object is a phantasm][last seen object][perform now last seen object is off-stage][otherwise][a last seen object][end if].";
	if last seen object is a phantasm:
		scare the player.

Rule for printing the name of a dark room:
	if the location is visited:
		say "[The location], [one of]in Darkness[or]in the Dark[or]you think...[or]probably[or]supposedly[or]you would imagine[or]Hopefully[as decreasingly likely outcomes]";
	otherwise:
		say "[one of]An Unfamiliar Room[or]Somewhere in Darkness[or]Somewhere in the Dark[or]A Dark Room[or]A Dark Place[or]Not Sure[or]Somewhere[or]In the Dark[as decreasingly likely outcomes]".
		

[...]

Chapter 1 - Images
	
An image is a kind of thing.

a thing has a text called ptext.  A room has a text called ptext.  A backdrop has a text called ptext.  The ptext of a thing is usually "[generic]".  The ptext of a room is usually "[generic]".  The ptext of a backdrop is usually "[generic]".

To say generic:
	say "[one of]It's a[or]A[at random][one of] good[or] decent[or] fairly good[or] nice[or] passable[or]n artistic[or][as decreasingly likely outcomes] [one of]shot[or]picture[or]image[or]angle[or]cap[as decreasingly likely outcomes] of [the noun]"
			
Recalling is an action applying to one visible thing.  

Understand "recall [any known thing]" and "review [any known thing]" and  "evaluate [any known thing]" as recalling.  Understand "examine [any known thing]" as recalling when the noun is not visible and the noun is captured.

Understand "recall [any known backdrop]" and "review [any known backdrop]" and  "evaluate [any known backdrop]" as recalling.  Understand "examine [any known backdrop]" as recalling when the noun is not visible and the noun is captured.

Understand "recall [any known room]" and "review [any known room]" and  "evaluate [any known room]" as recalling.  Understand "examine [any known room]" as recalling when the noun is not visible and the noun is captured.

Understand "r [something]" as recalling.

Check recalling:
	if the noun is not known:
		say "[one of]What are you talking about?[or]I'm not sure I know about that.[stopping]"

Check recalling:
	if the noun is not captured:
		if the noun is visible:
			try examining the noun instead;
		otherwise:
			say "You vaguely remember what [the noun] looked like." instead.
		
Check recalling:
	if the player does not have your camera:
		say "You think you might have an image of that on your camera." instead.
		
Check recalling:
	if compartment contains a discharged battery:
		say "The camera battery is dead." instead.
		
Check recalling:
	if compartment does not contain a battery:
		say "There's no battery in the camera." instead.
		
Report recalling:
	say "[ptext of the noun].".
			
Understand "picture/photo/snapshot/pic/snap/shot/image of" as a thing when the item described is captured.

Understand "picture/photo/snapshot/pic/snap/shot/image of" as a room when the item described is captured.

Does the player mean recalling a captured thing: it is very likely. 

The entire source for Transparent is available on itch in the game download section. There is a .txt though if you really want it it’s most easily readable as a formatted webpage from the index.html file in the folder provided by Inform 7.

1 Like