EDIT: Never mind – I got it. The term I need is ‘entries.’ “If the number of entries in L is 3” compiles and works.
I’m sure there’s a simple way to do this, but I’m not finding the syntax in the Documentation. I want to find out how many things are in a container. Some of the things in the container are scenery, so they won’t be moving, but there may be other (movable) things. If there is nothing in the container but the scenery bits, I want to have the Report rule give a non-default response, while if there IS something else, I’ll let the parser just mention the stuff that’s interesting.
Here’s the code that doesn’t work:
Report searching the urn:
let L be the list of things in the urn;
let M be the count of things in L;
if M is 3:
say "There's nothing in the urn but dirt, cigarette butts, and a sad palm tree.";
rule succeeds.
I’ve tried it with “let M be the total of items in L,” all sorts of terms like that, but nothing I’ve tried compiles.
Update to old question.
I don’t want to know the number of things in my container, a showcase. I want to know the number that matches a certain noun. > BUY 2 oil skeins
The noun is oil skein. How many oil skeins in my showcase?
let N be the number of things in the urn;
compiles and gives the right answer but
let N be the number of noun in the showcase; or
let N be the number of things in the showcase that matches noun;
does not. I get a compile error on the misuse of LET N.
How do I match the noun with the “number of” phrase?
The docs say number of (description of values) … number
and number of nouns in the showcase is recognized as a description of values, so I think something else is going on here.
EDIT: A little more clarification. I am trying to compare the number requested (number of entries in multiple object list is 2) with the number in the showcase (the number of things that match the noun), which is 1 for oil skein. I don’t know how to phrase the latter.
If I understand correctly, what you ultimately want to be able to do is to count items that have the same kind as the noun, right?
Unfortunately, I’m not sure how you would do that. I thought maybe you could define a phrase that answers the question using kind variables, but I couldn’t think of a way to make it work.
When I made that earlier example for you part of the reason I gave specific, late-in-the-line kinds a number called “bulk-identifier” was specifically to circumvent this problem. When you think about it, a single thing can have a lot of kinds. A vehicle is a vehicle, but it is also a container and a thing and an object. By manually defining a bulk-identifier for things I wanted grouped (and assuming the contents of a showcase would be strictly controlled to only include things with bulk-identifiers), however, I could create artificial exclusive “kinds” to derive any necessary information from.
I am trying to compare the number requested (number of entries in multiple object list is 2) with the number in the showcase (the number of things that match the noun), which is 1 for oil skein.
The other reason, and why I made buying multiple things only work for one kind of thing at once, is that you can’t be certain a player is typing “BUY 2 OIL SKEINS” and not “BUY OIL SKEIN AND ARROW”. The use of bulk-identifier and then comparing it to everything in the multiple object list was to prevent both of those from causing you to buy 2 oil skeins.
Understand "buy [things]" as buying. and not write a bulk-action rule. I did both and using the default [Understand "buy [something]" as buying. incorporates all the safety checks and is cleaner.
This restricts buying to 1 or more multiples of the same kind, so that things like BUY OIL SKEIN AND ARROW do not happen.
Since the default action calls repeatedly the BUY action, I merely had to restrict the Check rule and Safety rule to a single iteration of the multiple object loop. The code below handles both single and multiple BUYing.
Check buying something when location is Emporium:
let Q be the number of entries in multiple object list;
if Q is 0: [single item is 0 in multiple object list]
now Q is 1;
if BulkCounter is 0:
now BulkCounter is Q;
...
Report buying:
if BulkCounter is 1:
...
decrement BulkCounter;
BulkCounter is an extra-loop variable that tracks how many times Check, Carry out, and Report are called.
Oh, my example didn’t create a separate bulk-buying action. It was all just the preexisting buying action.
Anyways, the reason I mention this is just that grabbing the kind of a noun is a bit tricky since one can (and typically does) have several. If you find a way to manually separate things like the bulk-identifier I used, however, you can try making comparisons to that to simulate the behaviour you’d like.
I saw that you put a lot of work in your suggestion. I spent several days getting bulk buying to work and handle the check exceptions without redundancy.
I appreciate you working with me on this.