How to look through a window

How do you code to look through a window?

That very much depends on what you want to be visible through the window, etc. Do you have a sample transcript of how you’d like the game to work?

1 Like

I have created two rooms, one is an apartment and the other one is the landscape.

The window is between the two rooms.

The Sprawled-Landscape window is in the Apartment. The Sprawled-Landscape window overlooks the Sprawled-Landscape. The printed name of Sprawled-Landscape window is "window".

Hope this help

What I mean is how do you want the text to look when you’re next to the window? There are a lot of choices.

Through the window you can see the kitchen.

Through the window you can see the kitchen. [full description of kitchen]

Through the window you can see:
Kitchen
[full description of kitchen]

Not to mention, do you want to see what NPCs are doing in the kitchen? Are there any things that are not visible through the window, etc. etc.

2 Likes

I want to see the description of the other side of the window and the objects that are visible as if you where in the room.

I also want to see what other actions is taking place in the other room.

Here’s one way to accomplish the first. I’m not sure about a general way to accomplish the second.

"Farseer" by Philip Riley

Lab is a room. "The lab looks out onto a garden:

[describe garden]".
Farseer is an undescribed person. It is in the Garden. It is privately-named.

To say describe garden:
	now the player is farseer;
	try looking;
	now the player is yourself;

Garden is a room. "The flowers are pretty."

This one is a bit more refined:

"Farseer" by Philip Riley

Lab is a room. "The lab looks out onto a garden:"

Farseer is an undescribed person. It is in the Garden. It is privately-named.

After looking when the location is the Lab:
	now the player is farseer;
	try looking;
	now the player is yourself;

Garden is a room. "The flowers are pretty."

Not entirely sure where the window fits in this solution.

I want something like

Instead of looking through a window when a room (called the far side) is adjacent:
	try examining the window.

So if you type

look through window

you should get the description of the other side and what is happening there.

Not sure how else to describe my problem.

Oh, I see, you want to have the player actively initiate looking through the window. The same trick works, but it should be triggered by examining or looking through (searching).

"Farseer" by Philip Riley

Lab is a room. "The lab looks out through a window onto a garden."
The window is a backdrop. The window is in the Lab and the Garden.

Farseer is an scenery person. It is in the Garden. It is privately-named.

Instead of examining the window when the location is the Lab:
	look through lab window;

Instead of searching the window when the location is the Lab:
	look through lab window;
	
To look through lab window:
	say "Through the window you see:[paragraph break]";
	now the farseer is in the garden;
	now the player is farseer;
	try looking;
	now the player is yourself;

Instead of examining the window when the location is the Garden:
	look through garden window;

Instead of searching the window when the location is the Garden:
	look through garden window;
	
To look through garden window:
	say "Through the window you see:[paragraph break]";
	now the farseer is in the lab;
	now the player is farseer;
	try looking;
	now the player is yourself;

Garden is north of the lab. "The flowers are pretty."
There is a ball in the Garden.
Fred is a man. He is in the Garden.

Test me with "x window/n/look through window"
1 Like

Thanks, I will have a look at your example and see how I can fit it into my project.

Everything seems to work but I keep on getting this error when looking through the window:

Run-time problem P45: Attempt to change the player to a person off-stage.

I can not figure out where i made a mistake.

This is the code:

Sprawled-Landscape is a room. 

The window is a backdrop. The window is in Apartment1 and Sprawled-Landscape.

In the Sprawled-Landscape is a vehicle called Vehicle. 
Farseer is an scenery person. It is in the Sprawled-Landscape. It is privately-named.

Instead of examining the window when the location is Apartment1:
	look through Apartment1 window.
	
Instead of searching the window when the location is Apartment1:
	look through Apartment1 window.

To look through Apartment1 window:
	say "Through the window you see:[paragraph break]";
	now the farseer is in the Sprawled-Landscape;
	now the player is farseer;
	try looking;
	now the player is yourself;

Instead of examining the window when the location is the Sprawled-Landscape:
	look through Sprawled-Landscape window;

Instead of searching the window when the location is the Sprawled-Landscape:
	look through Sprawled-Landscape window;
	
To look through Sprawled-Landscape window:
	say "You can't see into Apartment1 as the thick curtains block your view.";
	now the farseer is in the Apartment1;
	now the player is farseer;
	try looking;
	now the player is yourself;
	
Sprawled-Landscape is north of Apartment1. "Everything look so peaceful"

Please advice

I can’t make that happen. Are you sure the code you pasted here is exactly what you were running??

Just like that.

What can be the cause of the problem or where might I start searching for the problem?

The problem is that the player is getting moved off-stage (“nowhere”), presumably because farseer is off-stage. But it’s not off-stage. Are you using this with some other code?

I have pasted your code exactly as you gave and replace that part of mine. This what the output give me:

lab
The lab looks out through a window onto a garden.

>look through window
Through the window you see:

Garden
The flowers are pretty.

You can see a ball and Fred here.


*** Run-time problem P45: Attempt to change the player to a person off-stage.

As you can see everything seems to work but somewhere it can’t find my player on stage.

Yes in my project with loads of other code already in there.

It seems to work but the it don’t

Check that all of the room names are the same and correct.

Will do