Expand "asking it for" so that it allows "[someone], I want [something]"

Is there a way to slightly expand the “asking it for” action—as in ASK SALLY FOR THE EGG WHISK—so that it can be called with: SALLY, I WANT/NEED THE EGG WHISK?

In general, I don’t see how one can write an “understand” rule that starts with the first or second noun, for an action. This isn’t allowed:

Understand "[someone], I want [something]" as asking it for.

I understand that commands starting with an NPC’s name get manipulated under the hood, but I’m wondering if the Inform 7 user has a way to fiddle with this manipulation…

You don’t need to include the person asked in the Understand grammar, that is taken care of ‘under the hood’ in the parser.

Understand "[someone] want/wants/need/needs [something preferably held]" as giving it to (with nouns reversed).

looks as though it should work, and indeed it does if the player is the actor (.e.g. ‘Mr Darcy needs the glasses’ results in an attempt to give the glasses to Mr Darcy) but unfortunately the parser assumes that any command to another person starting with a matched token that is not a verb is an attempt at conversation, so ‘Darcy, I need the glasses’ gets diverted to 'answering Mr Darcy that “I need the glasses” '.

The only way I can see round this is to use ‘After reading a command’ to rearrange the command to something the parser will recognise:

After reading a command:
	If the player's command includes "I want/need":
		replace the matched text with "give me";
1 Like

The cleanest way is to recognize “I WANT THE WHISK” as a command, and then permit it as a command which can be given to NPCs.

[Ensure that "Sally, give me the spoon" works.]

Persuasion rule for asking people to try giving:
	persuasion succeeds.

The block giving rule is not listed in any rulebook.

[Define "I want the spoon" as an action.]

Self-giving is an action applying to one thing. 

Understand "i want [something]" as self-giving.

Check self-giving when the actor is the player:
	instead try taking the noun.

Persuasion rule for asking a person to try self-giving: 
	persuasion succeeds.

Instead of someone self-giving something:
	try the actor giving the noun to the player;
	stop the action.

I didn’t try to handle the full generality of “PERSON WANTS NOUN”, but I don’t think that’s needed here.

1 Like

Here’s another approach, which uses the ‘supplying a missing second noun’ activity to sort out an actor and/or recipient for the existing ‘giving it to’ action.

This example handles a plain ‘I want …’ by trying to find a nearby person who could fulfil the request (who either already has the item requested, or, if nobody already has it, could take it and hand it over). The algorithm, prefers humans to animals, but will allow animals to fulfil the request if there’s not a block giving rule to prevent it.

Understand "I want/wants/need/needs [something preferably held]" as giving it to.

Rule for supplying a missing second noun while an actor giving something to:
	let the original actor be the person asked;
	if the person asked is the player:  [I want ....]
		now the person asked is the owner of the noun; [find out if anyone's got it, if so ask them for it]
		if the person asked is nothing: [if no-one's got it, choose a random man or woman who can get it to ask]
			now the person asked is a random touchable other human person which can touch the noun;
		if the person asked is nothing: [if no-one's got it, choose a random person in the location who can see it to ask]
			now the person asked is a random touchable other person which can touch the noun;
		if the person asked is nothing: [still no-one]
			say "Nobody nearby [can] give [if the original actor is the player][us][else][the original actor][end if] [regarding the noun][those].";
			now the person asked is the original actor;
			rule succeeds;
		if the person asked is the original actor: [asker is the owner]
			say "[The person asked] already [have] [regarding the noun][those].";
			rule succeeds;
	now the second noun is the player; [ask to give it to the player]

Definition: a person is human if it is not an animal.
Definition: a person is other if it is not the player.
	
The block giving rule is not listed in any rulebook.
	
To decide which object is the owner of (O - an object):
	if O is nothing:
		decide on nothing;
	let the local ceiling be the common ancestor of the person asked with O;
	let the owner be the not-counting-parts holder of O;
	while the owner is not nothing and the owner is not the local ceiling:
		if the owner is a person:
			decide on the owner;
		let the owner be the not-counting-parts holder of the owner;
	if the owner is the person asked:
		decide on the person asked;
	decide on nothing;

This leads to output like this:

Lab
Mr Darcy haughtily haunts the hall in a blue frock coat.

You can also see the Lab door, a workbench (on which are a CD box (closed) and a hat), a sideboard (on which are a teatray (on which is a teapot), a knife, a fork, an apple, a salad server and some cruets) and a cupboard (empty) here.

>i
You are carrying:
  the hamster
  a pair of glasses (being worn)
  the plastic bag (closed)
    a starfish

>Darcy, I need a coat
(first taking the blue frock coat off)
Mr Darcy gives the blue frock coat to you.

>Darcy, I need a knife
(Mr Darcy first taking the knife)
Mr Darcy gives the knife to you.

>I need a fork
(Mr Darcy first taking the fork)
Mr Darcy gives the fork to you.

>Darcy, go north
Mr Darcy goes north.

>I need an apple
(the hamster first taking the apple)
The hamster gives the apple to you.

>starfish, I need the teapot
(the starfish first taking the teapot)
The starfish is unable to do that.

>I need the glasses
You already have those.

>drop hamster
Dropped.

>hamster, go n
The hamster goes north.

>I need a teapot
Nobody nearby can give you that.


1 Like