In case you’re interested, I worked away at this a little more and added some improvements:
[rant][code]Waiting Room is a room. A bill is a kind of thing. A cost is a kind of value. 2 dollars specifies a cost. A bill has a cost called price. The price of a bill is usually 5 dollars. The player carries two bills.
Bonk is a bill.
A mint is a kind of thing. A dish is a container in Waiting Room. Six mints are in the dish.
Counting is an action applying to one touchable thing.
Understand “count [things]” as counting.
Understand “count [things inside] in/on [something]” as counting it from. Counting it from is an action applying to two things.
Carry out counting it from: try counting the noun instead.
Currently counting is a truth state that varies. Currently counting is false.
To decide whether (fiscal - a list of objects) is monetary:
repeat with item running through fiscal:
if item is not a bill, decide no;
decide yes.
First check counting:
if currently counting is true:
stop the action. [This is what cuts off the count for the rest of the items on the multiple object list.]
Report counting a carried bill:
now currently counting is true;
if the multiple object list is monetary:
say “You’re carrying [a list of bills carried by the player]. You have [the total price of bills held by the player].[paragraph break]”;
rule succeeds. [This line stops the report counting rulebook, so you don’t fall through to the next rule]
Report counting something:
now currently counting is true; [This sets the flag so we don’t keep doing it]
let L be the multiple object list;
if the number of entries in L is less than 2: [If we’re only counting one thing, then there will be 0 objects in the multiple object list, so we need a special case]
say “One!”;
otherwise:
let T be indexed text; [AFAIK you have to do this to get the word capitalized]
now T is “[the number of entries in L in words]”;
now T is T in sentence case;
say “[T]![paragraph break]”
The before-generation rule is listed before the generate action rule in the turn sequence rules.
This is the before-generation rule: [the documentation for example 420 explains why we need to do it this way]
now currently counting is false.
The selectively announce items from multiple object lists rule is listed instead of the announce items from multiple object lists rule in the action-processing rules.
This is the selectively announce items from multiple object lists rule: [This means that we don’t get a bunch of “mint: mint: mint:” when we’re trying to count]
unless counting or counting something from something: [this is just the normal behavior for this rule]
if the current item from the multiple object list is not nothing:
say “[current item from the multiple object list]: [run paragraph on]”.[/code][/rant]
The business about “counting it from” is basically straight out of the “Left Hand of Autumn” example – it means that “count everything in the dish” now gives you the number of things that are in the dish. You’ll notice that when it comes time to carry out counting it from, we just ignore the second noun; it’s in there just to restrict the “all” to the things inside the second noun, as per the Understand line.
Then the definition of a monetary list is there to take care of the thing I mentioned about “count one bill and two mints” – counting bills will only give you the special bill message if you’re exclusively counting bills and if you have at least one bill. If there’s something else in the object list (it’s not a “monetary” list), then that rule doesn’t do anything – in particular, it doesn’t trip the “rule succeeds” condition which ends the rulebook, so it goes on to execute the other report counting rule. I couldn’t figure out a more direct way to express the condition that everything in a given list is a bill.
It looks like I used some chicanery – if you’re carrying a bill and another bill is visible, then which rule gets executed depends on which bill is first in the multiple object list. I think that in this case the carried bill is always going to be first, but in a more general case you probably want to make sure that you do the money count whenever the whole list is bills and there’s a carried bill anywhere in the list.