List contents of room within a rule

This seems like such a simple task, but I cannot find an example with searching and nothing I have tried works.

I have custom descriptions for every room, and I am able to list all the valid directions from the room. But the custom listing omits the list of objects in the room. I want to add that list at the bottom, just as the non-custom room description has. As if the rule said ‘now player is looking at the room’

How are you customizing the room descriptions?

Here is an example:

After going to a room:
	say "[bold type][location][roman type][lb]";
	if location is unvisited:
	    say description of location;
		now location is visited;
	say getDoors applied to location;
	say "[lb]".

I suppose a more general concept would be executing a player action within a rule.

You’re reproducing work the standard rules are already willing and able to do. You can eliminate that rule and accomplish the equivalent with:

Use brief room descriptions. [ make it so that the room description is given only the first time. ]
Last report looking: say getDoors applied to location. [ print your exit list ]
1 Like

Thank you, nearly perfect. I had not seen ‘Last report looking’ before. As you say, just what I need.

Except that I should have posted the full rule, as I did before editing for simplicity. The full rule includes this after the above:

		if ghost is in location:
			say "[lb]The room is dark, and eerily cold. There is a breeze rushing over your ankles, and one rushing past your left ear.  Against the far wall, you see a darkly translucent figure of a young person. The figure is wearing a formal tuxedo with bright red bow tie and shiny white shoes. A large gold pocketwatch dangles from the waistcoat[pb]The figure's mouth is wide open as if screaming, and it looks angry. It is terrifying. You realize the breezes are coming from its mouth.";
			the egg-timer clucks in 1 turns from now;
		otherwise:
			if corpse is in location:
				say "[lb]There is a corpse lying in the middle of the floor.";

Figured out how to patch those in – just put them as more lines after Last report looking:

Thank you!

If you give your things initial appearances, they will be printed when the player looks while in the room (which happens automatically on going to a room) until they are handled, which normally happens only when the player successfully takes them, so probably won’t happen here since I imagine these are both not portable.

Do I guess correctly that the ghost and the corpse were the same person in life and the player is meant to see the corpse only after the ghost has somehow been dealt with?

The ghost is a thing. "The room is dark...". The ghost is in the Parlor.
The corpse is a thing. "[lb]There is a corpse lying in the middle of the floor.". [not given a location so it's off-stage.]
Every turn when the ghost is in the location: the egg-timer clucks in 1 turns from now.

then in some rule recognizing that the player has set the restless spirit to rest…

now the ghost is nowhere.
move the corpse to the Parlor.

Ha! Yes, in concept, but the reverse. (Neither is handled, that is correct.) The corpse appears first (it is really a red herring, there are many such in the story), then after it is examined, it disappears (to nowhere) and the ghost arrives in a different room. When the ghost is met, the game ends either ghost-busted (with the right spell) or frightened to death by the ghost. A very simple story I wrote for my grandkids for a Halloween party (https://www.ideategames.org/zgames/hhouse/). It was fun for the party (adults had to figure out some of the movie-based clues), but an IFDB reviewer gave it a 1 because too many things in the room descriptions could not be examined or taken, were not actual objects. I made the room descriptions long and more story-like because of my audience and for atmosphere. C’est la vie. That is why I wanted to force a look on each room visit, so readers would know which actual objects are in the room. But I guess if I wanted to do more stories, I need to make a lot more objects to match the descriptions. A difference between story expectations and game expectations.

The reason I have these descriptions in the rules is that the descriptions on first encountering in the room are different from the more detailed descriptions for ‘examine’ of these, and different again depending on if the player has the cat. The rule as I have shown is not as complicated as the actual code. And, player does not get a chance to examine the ghost. If the first action is not the right spell, player loses. That might be harsh, but I needed the story to be brutal for the party.

Still early days learning about IF, and what I can do with it. This was an exploration of getting the reader to do research to understand the clues. (My interest is in education.) In this case, the ‘research’ was just asking an adult or doing a simple translation of Latin, but I plan to move on from that.

I appreciate the suggestions. I could make it a bit simpler following your design. Thanks.

The different description on first entering the room from what you get with examine is exactly what the difference between things’ initial appearance and description properties is for. And both could be written like "[if the player carries the cat]catty text[else]uncatty text[end if]". It sounds a lot like you could accomplish what you want there with existing tools, which would keep your rules simpler, which will make your life easier as you tackle larger games.

2 Likes

Thank you, I agree. I have seen if/else within descriptions in some examples, but have only implemented basic ones. Existing tools are always better, I just have to learn them. Thanks for the help.

As for scaling up, what I really need for my style of programming is an efficient include function, I am used to dividing everything up into ‘small’ files. Not with the built-in include that requires installing modules (it would be crazy to install room descriptions), but just a simple way to divide the story up into separate files. But I am doing fine with this so far, it is a great framework, and I am having a lot of fun learning it. Last report is a very big step forward.