"try"-ing actions with one noun and one number

I’ve run into a bit of a snag here.

I have a custom “Buy” action that allows the player to buy one or more of a certain object. It is a single object with a ‘count’ variable to keep track of how many of it is owned by the player. Here’s how it looks like:

Stuffbuying is an action applying to one visible thing and one number. Understand the command "buy" as something new. Understand "buy [a number] [any thing]" as stuffbuying (with nouns reversed).

This works fine. So I decided, for player convenience, that I would add a little shortcut command. If the player only wants to buy one thing, they should type, for example, “buy friend.” This is where I ran into trouble. I noticed that no matter how many items the player tries to buy, the action is technically “stuffbuying the (item)” without the number specified.

Sure enough, it seems like there is no obvious way for me to tell inform to specifically buy any particular number of an item. If I do “try stuffbuying 1 noun” or “try stuffbuying noun 1” it will not compile. If I only use “stuffbuying noun” Inform seems to use the number 0. Is there a specific method to handing “try” in this situation that I’ve overlooked? Maybe some way of making it pass on the desired number to the action?

You’ve defined stuffbuying as applying to the noun and then the number, so “stuffbuying one noun” doesn’t seem to be a valid action description; it should be “stuffbuying the noun one.” However, when I tried it that confused the compiler, so I tweaked it so the action description was “stuffbuying the noun times one” and that seemed to work:

[code]Stuffbuying it times is an action applying to one visible thing and one number.
Understand the command “buy” as something new.
Understand “buy [a number] [any thing]” as stuffbuying it times (with nouns reversed).

Report stuffbuying it times:
say “You would like to buy [the number understood] of [the noun].”

Vaguelybuying is an action applying to one thing.
Understand “buy [any thing]” as vaguelybuying.
Instead of vaguelybuying: try stuffbuying the noun times one.[/code]

I had a cherry kind already defined in the test code I was trying this out on and I noticed that the game gave me a “You can’t use multiple objects with that verb” error when I tried “buy 3 cherries,” but “buy 3 cherry” worked as intended. This happened even when I changed the understand line to “buy [a number] [any things].” And when I tried “buy [a number] [things]” the command “buy three cherries” carried out the stuffbuying action for every cherry in the location. I guess you would need to do one of those multiple-object-list manipulations in order to get around this if necessary.

I can’t help but think that there’s a more straightforward way to do what you want, though I’m not sure what.

Oh, don’t worry about the plural thing. I got that covered and just omitted that code. The way I’m doing it is having there be a single object that has “a number” keeping track of how many the player owns. Because there is only one, I have inform understand the plural version as the item.

As for the issue at hand, your solution works and I do thank you. Funny how it’s these little “convenience” features that cause me all the trouble while the rest of the game itself is a-okay.