How would I program this window with a flowerpot outside of it?

I’ve been trying to program a window with a flowerpot outside of it. I wanted the flowerpot to only be takeable if the window is open, but I didn’t want the player to be able to put stuff inside the window. I didn’t want the flowerpot to be revealed in the “open window” report text, and I also didn’t want the contents of the window to be listed after the description. I couldn’t figure out how to do the latter, so I made window not a container. The following code does not work:

The Scorched Room is a room. "Burn marks cover the rough stone walls. Ash and soot covers the floor, and burned wooden wreckage and broken glass is scattered around various points in the room. A round door, with one side completely blackened, is to the west. A hinged circular window is [if circular window is closed]closed[otherwise]open[end if] on the opposite side of the room."
The circular window is scenery in the Scorched Room. The circular window can be open or closed. It is closed.
Instead of opening the window:
	say "You open the window, letting some fresh air in.";
	now the window is open.
Instead of closing the window:
	say "You shut the window.";
	now the window is closed.
The description of the circular window is "[if closed]The window is so covered with soot that you can't see out of it.[otherwise]A nice field of rolling green hills is outside the window. There is an empty window box outside and underneath the window[flowerpot there].".
To say flowerpot there:
	if the flowerpot is in item limbo:
		say ", and an empty flowerpot is sitting in it".
Instead of taking the flowerpot in the scorched room:
	if the circular window is open:
		move the flowerpot to the player.
The flowerpot is in item limbo.

The “instead of taking the flowerpot” line does not ever activate. When you try to take the flowerpot, you just get “You can’t see any such thing.” I’m sure the above code is terrible and there’s a much more concise and less roundabout way of doing this, but I have no clue how to do it. Any help is much appreciated.

1 Like
A circular window is here.  It is scenery and a container.  It is closed and openable.
After opening the circular window:
    say "You open the window, letting in some fresh air."
After closing the circular window:
    say "The window clicks shut."
The description of the circular window is "[if closed]The window is so covered with soot that you can't see out of it.[otherwise]A nice field of rolling green hills is outside the window.  There is [end if][if the circular window is open and the flowerpot is in the circular window]a [flowerpot] in the window box outside of the window[otherwise if the circular window is open]an empty window box outside of the window[end if]."
Check inserting something into the circular window when the circular window is open:
    if the noun is not the flowerpot:
        instead say "Only your sweetheart's flowerpots go there!"
The examine containers rule does nothing when the noun is the circular window.

The After opening rule will supplant the ‘Opening the … reveals’ message (which is from a Report rule, which After rules always cancel out).
The examine containers rule is the one that carries the message ‘In the…you see’ when examining a container. You can void it by saying the above.
You can make the window a container–and a very limited container–by including a Check rule that excludes everything other than the flowerpot, like the rule above.

I hope that this helps!

EDIT: In the description, I forgot to add [if the circular window is open and …] to the description of the window–otherwise if the window were closed, it would print one of the messages about the flowerpot or the empty window box as if the window were open. My bad.

2 Likes

I would probably cheat and make the window a transparent container that is fixed in place with scenery inside of it, and also a supporter called “windowsill” with the flowerpot on it. That might require capturing and redirecting some stuff like “look out window” to “look in window”. Might not be the best idea though.

EDIT: WHAT @EpicIFer SAID!

2 Likes

Forgot about the redirect—

Understand "look out [something]" as searching.
Instead of searching the circular window:
    try examining the circular window.

Since you’re probably going to have the same description for ‘look in’ or ‘look out’ as for ‘examine’ for the window.

1 Like

Just for the sake of completeness and for reference, another approach is described in the Recipe Book, Chapter 3.6. “Windows”, example 217: “Dinner is Served”.

3 Likes

You know, Hanon’s idea is also quite valid–you can put a supporter (the window box or windowsill) inside the window, and neither it nor the pot will be visible if the window is closed. And really you need not worry about an ‘In the … you see…’ message in the room description (by ‘looking’, as opposed to ‘examining’), as by the standard rules, things placed inside other things are assumed to be ‘invisible’ upon entering a room until you examine the container. And if you somehow include the [name of the item] within the container’s description, in brackets, that can also prevent the ‘In the … you see…’ message when you examine the container–so I was redundant in my code, by including the ‘The examine containers rule does nothing…’ line.
I really hope I was helpful, as I have a reputation for explaining things to death, as Hanon knows!

1 Like

I saw this question and made an attempt at coding an example. I suspect there are better approaches but I thought I would post it anyway in case it could be of help. Your mileage may vary :slightly_smiling_face:

The scene is a Bedroom with a window looking onto a Grassy Slope. On the window sill outside of the bedroom on the other side of the window are several objects: a flower, quartz crystal, and a vase. The objects cannot be reached when the player is inside the bedroom and the window is closed; however, they can be seen if the player chooses to look through the window. If the player opens the window they can reach the objects on the window sill. Cases such as inserting and removing objects from containers on the window sill are also handled. The player can also climb through the window. When the player is in the Grassy Slope all objects on the window sill are within reach regardless of the open / closed status of the window. The window sill moves with the location of the player in order to provide access to objects on the window sill; however, if the window is closed access from the bedroom is prevented.

Note the basis for this example is: Example 21 “Escape” from section 3.6 Windows

Here is the code I wrote:

Your Bedroom is a room. The bedroom window is a door. It is west of Your Bedroom and east of the Grassy Slope. The window sill is a supporter in the Grassy Slope.    It is undescribed.  There is a flower on the window sill.  There is a quartz crystal on the window sill.  There is a vase on the window sill.  The vase is an open container.

Does the player mean opening the window sill: it is very unlikely.
Does the player mean closing the window sill: it is very unlikely.
Does the player mean searching the window sill: it is very unlikely.
Does the player mean climbing the window sill: it is very unlikely.
Does the player mean examining the window sill: it is very unlikely.

When play begins:
	now the sill is in the location.
	
After going to Your Bedroom:
	now the sill is in the location.

After going to Grassy Slope:
	now the sill is in the location.
	
Before opening the window when the location is Your Bedroom:
	now the sill is in the location.
	
Instead of searching the window:
	say "Through the [if the window is closed]closed [end if]window, you make out [the other side of the window] [if there are any objects on the window sill]and a [list of objects on the window sill] resting on the window sill[end if][if the location is Your Bedroom] outside[end if].";
	now the sill is in the location;

Instead of inserting something into a container on the window sill:
	if the player is in Your Bedroom:
		if the bedroom window is closed:
			say "The window is shut: you'd break the glass.";
			stop the action;
		otherwise:
			continue the action;
	continue the action.
		
Instead of removing something from a container on the window sill:
	if the player is in Your Bedroom:
		if the bedroom window is closed:
			say "The window is shut: you'd break the glass.";
			stop the action;
		otherwise:
			continue the action;
	continue the action.

Instead of taking something:
	if the noun is in a container on the window sill:
		if the player is in Your Bedroom:
			if the bedroom window is closed:
				say "The window is shut: you'd break the glass.";
				stop the action;
			otherwise:
				continue the action;
	continue the action.
	
Instead of putting something on the window sill:
	if the player is in Your Bedroom:
		if the bedroom window is closed:
			say "The window is shut: you'd break the glass.";
			stop the action;
		otherwise:
			continue the action;
	continue the action.
	
Instead of taking something that is on the window sill:
	if the player is in Your Bedroom:
		if the bedroom window is closed:
			say "The window is shut: you'd break the glass.";
			stop the action;
		otherwise:
			continue the action;
	continue the action.
	
Instead of doing something to anything on the window sill:
	if the player is in Your Bedroom:
		if the bedroom window is closed:
			say "The window is shut: you'd break the glass.";
			stop the action;
		otherwise:
			continue the action;
	continue the action.
	
Understand "climb through [something]" as climbing. Understand "jump through [something]" as climbing.

Instead of climbing the window:
	try entering the window;
	try looking.

Instead of going through the closed window:
	say "The window is shut: you'd break the glass."

Here is how the code plays out when attempting to manipulate objects on the window sill when the window is open or closed.

Your Bedroom
You can see a bedroom window here.

>look through window.
(the bedroom window)
Through the closed window, you make out the Grassy Slope and a flower, quartz crystal and vase resting on the window sill outside.

>take all.
flower: The window is shut: you'd break the glass.
quartz crystal: The window is shut: you'd break the glass.
vase: The window is shut: you'd break the glass.

>examine sill
On the window sill are a flower, a quartz crystal and a vase (empty).

>open window.  take flower.
(the bedroom window)
You open the bedroom window.

Taken.

>climb through window
(the bedroom window)
Grassy Slope
You can see a bedroom window here.

>put flower in vase.
You put the flower into the vase.

>examine sill
On the window sill are a quartz crystal and a vase (in which is a flower).

>close window.
(the bedroom window)
You close the bedroom window.

>e
The window is shut: you'd break the glass.

>open window
(the bedroom window)
You open the bedroom window.

>e
>take all
quartz crystal: Taken.
vase: Taken.
flower: Taken.

>close window
(the bedroom window)
You close the bedroom window.

>put all on sill
flower: The window is shut: you'd break the glass.
vase: The window is shut: you'd break the glass.
quartz crystal: The window is shut: you'd break the glass.

>open window.
(the bedroom window)
You open the bedroom window.

>put flower in vase.
You put the flower into the vase.

>put all on sill
vase: Done.
quartz crystal: Done.

>examine sill
On the window sill are a quartz crystal and a vase (in which is a flower).
1 Like

Thank you everyone for the help! I’ll be sure to experiment with all of this advice :slight_smile: