When taking the last item from a supporter

I want to print special text when you take the last item off of a supporter. In this scenario, you’re having breakfast, and you can eat the foods in any order. I want to print special text before you eat the last thing on the plate. Is there a simple way to check if a supporter will be empty after taking something, and react accordingly?

"The Most Important Meal of the Day" by Scrooge

Dining Room is a room.

The dining table is in the Dining Room. The plate is on the dining table. The description of the plate is "On the plate is [is-are a list of (things on the plate)]".

The bacon, eggs, and danish are edible.

The bacon is on the plate. The indefinite article of the bacon is "some". Some eggs are on the plate. On the plate is a thing called a danish. A danish is improper-named.

Report eating the bacon: say "You grab the bacon and eat it. Crispy!" instead.
Report eating the eggs: say "You eat the scrambled eggs. They're salted!" instead.
Report eating the danish: say "You eat the danish. It could use some butter." instead.

[Before taking the last thing on the plate:
	say "Last but not least, you finish off your breakfast with [the noun].";]

When play begins: say "It's time for breakfast!"

Thanks in advance!

One way to phrase the rule would be:

Before taking an edible thing on the plate when the number of edible things on the plate is 1:
	say "Last but not least, you finish off your breakfast with [the noun].";

I restricted it to edible things here, to prevent scenarios where the player puts something else on the plate and takes it, and so on.

Edited to add:
A general phrasing would be:

Before taking something on a supporter (called S) when the number of things on S is 1:
	say "You decide to grab [the noun], after which there'll be nothing left.";

Though note, for both examples, that if the taking action fails for some reason that comes later in the action processing, then the text printed by the Before rule could be misleading.

We could also slip in our message a bit later in the action processing, like this:

First carry out taking something on a supporter (called S) when the number of things on S is 1:
	say "You decide to grab [the noun], after which there'll be nothing left.";
3 Likes

This is an interesting philosophical point.

If one takes the view that at the Before stage of the action the actor has only the idea of performing the action without yet having considered whether it is advisable or how it will be accomplished, before even consideration of whether there’s light to do it (basic visibility rule) or any involved objects are within the necessary reach (basic accessibility rule) or in hand (carrying requirements rule) -all of which run after Before and before Instead- saying “you have decided…” is not an incongruous report on how far the action has progressed at this point,the ultimate outcome being ‘you decided to do this… but were thwarted by (whatever later rule got in the way)’.

2 Likes

Past tense conditions can be useful here:

[use of After rules allows replacement of regular Report rule for special case]
After eating when the number of edible things on the plate is zero and the number of edible things on the plate was one:
	say "Last but not least, you finish off your breakfast with [the noun]."

[for cosmetic reasons and to limit need for special rules to only the eating action]
The can't eat portable food without carrying it rule does nothing when the noun is on the plate.

I also noticed a nuance worth paying attention to regarding what constitutes the initial declaration of the food items:

The bacon is on the plate. The indefinite article of the bacon is "some". Some eggs are on the plate. A danish is on the plate.

[moving edibility assignment to after initial declaration simplifies article issues]
The bacon, eggs, and danish are edible.

Your original declaration might be of interest to @drpeterbatesuk, because of the way that eggs are assigned proper-named status. He recently made a study of the nuances of noun declarations, but I’m not sure that it covered declarations using comma-separated lists.

4 Likes

It’s not philosophical, it’s a matter of programming style. You have some choice about how you want to use I7’s rule system.

My habit is that if I’m changing only the displayed text of a TAKE, I use a report rule. And look, you’re already using report rules. So I’d probably do this:

Report eating the bacon:
	if the number of edible things on the plate is zero:
		say "You finish off your breakfast with the crispy bacon." instead;
	say "You grab the bacon and eat it. Crispy!" instead.
	
Report eating the eggs:
	if the number of edible things on the plate is zero:
		say "You finish off your breakfast with the salty eggs." instead;
	say "You eat the scrambled eggs. They're salted!" instead.
	
Report eating the danish:
	if the number of edible things on the plate is zero:
		say "You finish off your breakfast with the rather stale danish." instead;
	say "You eat the danish. It could use some butter." instead.

The code is a bit repetitive, sure. So what, it’s done now, you can get on with the next room.

5 Likes

you’re obviously not going to get as far as Report rules- which may well be what you want rather than announcing a prior intention to do something.

I’d never be one to suggest a straitjacket. But it’s worth knowing that if you want to intervene or make announcements before light, carrying and accessibility are considered and may stop the action, a Before rule is the place to do it.