Actions with a noun and number

I finally got the BUY [something] action working but I want to BUY [Nbr] [something].
I have not seen an action that takes two nouns, except for people. I can’t seem to get the two-noun form working because it conflicts with the original default BUY.

Currently, I use BUY [something], then ask the player how many? I use that number to do what I want, but that is cumbersome. Any suggestions?

Repeat-buying it of is an action applying to one number and one thing.
Understand "buy [number] [thing]" as repeat-buying it of.

Then you can redirect buying to repeat-buying:

Before buying something: try repeat-buying one of the noun instead.

(Or ask the player for a number instead of defaulting to 1 if you prefer.)

And put all your rules in the new action.

1 Like

This looks good. I would never thought of the awkward phrasing this has, but I understand what it is trying to do.
I’ll give it a try.

No, I get a parser error on the first line:
Repeat-buying it of is an action appying to one number and one thing’: but the action definition contained text I couldn’t follow, and may be too complicated.

When I pasted that in the IDE, I didn’t like the look of that run of words ‘it of is’. And it failed to compile like Falsoon said.

I just renamed the action to bulk-buying, then it compiled.

Bulk-buying is an action applying to one number and one thing.
Understand "buy [number] [thing]" as bulk-buying.

‘of’ is a significant word to Inform, so personally I try to keep it out of the straight names of things and actions.

-Wade

1 Like

I renamed it to bulk-buying, but it still got an error on the corollary phrase, with the same error message.

Before buying something:
	bulk-buying one of the noun instead.

Do I need to insert a number in the statement

"Before buying (a number) something" ?

Youre missing a word: try bulk-buying one of the noun instead.

Duh! Thanks.

No good. I still get parser errrors.

Before buying something:
	try bulk-buying one of the noun instead.

Bulk-buying is an action applying to one number and one thing.
Understand "buy [number] [thing]" as bulk-buying.

Check bulk-buying something:
	if noun is not purchasable:
		say "That [noun] is not being sold. Perhaps you can just take it.";
		stop the action;
	otherwise:
		say "Trying to buy the [noun]";

Carry out bulk-buying something:
	say "1st noun = [first noun]          ";
	say "2nd noun = [second noun][line break]";
	if the player has something (called sibling) that pairs the noun:  [check if player already has it]
		say "You already have [sibling]. You can't wear another one, and it's too bulky to carry around with you." instead;
	otherwise:
		say "You slap down some coins to pay for [noun].";
		decrement qty of noun;
		now sibling is in location;
		now player is carrying sibling;
		say "You pick up the [sibling]."

What am I doing wrong?
(A few of these statements are for debugging.)

Interestingly, the parser error says "Try using ‘something’ rather than ‘it’, but I didn;t use ‘it’.
PROBLEM: You wrote ‘Check bulk-buying something’, which seems to introduce a rule taking effect only if the action is ‘bulk-buying something’. But that did not make sense as a description of an action. (I notice that there’s an action called ‘Bulk-buying’: the ‘it’ in the name is meant to be where something is specified about the first thing it acts on. Try using ‘something’ rather than ‘it’?) I am unable to place this rule into any rulebook.

try bulk-buying the noun instead
check bulk-buying
carry out bulk-buying

No, similar parser error.
Problem You wrote ‘try bulk-buying the noun’, but ‘bulk-buying the noun’ is not an action I can try. This looks as if it might be because it contains something of the wrong kind. My best try involved seeing if ‘noun’ could be a number, which might have made sense, but it turned out to be an object.

I think I’m going to give up on “BUY (number) (something)” because the parser can’t seem to handle a number and a noun.

You haven’t defined bulk-buying at that point in your code (the definition is later).

Didn’t matter. Parser confuses bulk-buying with buying and won’t let me redefine it.
Thanks for your suggestion though.

understand "buy" as something new?

You still need to move that bulk-buying definition above the before buying code.

I couldn’t work it out when I tried it today. However I didn’t really believe that it couldn’t be made to work.

I did a google search of this site for “one number and one noun” and the following topic was the top result. Try its observations and see if it helps:

-Wade

I have found that whenever you make an action with two nouns you should have a preposition in between. So for example here it should be

bulk-buying it of is an action applying to one number and one thing.

and then you should have an initial grammar line that uses the preposition. Subsequent lines can do the configurations without “of”.

2 Likes

I did that but the parser seems to have a problem with the block checking rule.
When I click on the doc to unlist it, another parser error!
I think I’ll report a bug in INFORM since the unlisting action is verbatim from the docs.

Yes, see code above.

I have solved the blocking rule for BUY. The docs give a parser error, but someone’s example worked fine.

Understand "buy (something)" as buying.
The block buying rule is not listed in the check buying rules. [Needed to allow BUY to work.]

Check buying something:
	if noun is not purchasable:
		say "That [noun] is not being sold. Perhaps you can just take it.";
		stop the action;

Carry out buying:
	if the player has something (called sibling) that pairs the noun:  [check if player already has it]
		say "You already have [sibling]. You can't wear another one, and it's too bulky to carry around with you." instead;
	otherwise:
		say "You slap down some coins to pay for [noun].";
		if VSpace contains something (called sibling) that pairs the noun:
			now player is carrying the sibling;
			say "You now have the [sibling]";
		decrement qty of noun; 

Since I have to tip the player that they need to enter a number (like 9 arrows), I will merely ask for how many after a BUY action.

Did you investigate that old thread I linked? I’m pretty sure BUY N OBJECTS is doable. I think it’s safe to say players will develop a frown at having to type two commands per purchase after the first time they experience it.

-Wade

2 Likes