Changing default response to someone not being there

Hi again. I understand that adjusting the parser’s default responses is possible. I’ve read a few examples but I’m always wary of fiddling with core functionality when I don’t really know what I’m doing (I feel like a 'talking" parrot a lot of the time).

In any case, just like me, my likely audience is not very familiar with IF so I want to help them make sense of what’s happening when I can.

As a result when they type “give flowers to Mrs Whip”, for example, if the person wasn’t there I’d like the parser to return “I don’t see them here” if the person was absent rather than “You can’t see any such thing” which is appropriate for a missing inanimate object.

My suspicion is that, based on the response to similar questions, this is quite a complex idea and I’d best leave it alone.

The problem is, by default, when the parser is giving that message it doesn’t have any idea that there’s a “Mrs Whip” somewhere else in the game. It just knows that the text you entered doesn’t correspond to anything you can see. (That’s why it gives the same response to “give flowers to aksidhkjshf”.)

The easiest way to change this is to define a new action with grammar like “give [something preferably held] to [any person]” which prints the error you want.

4 Likes

Unless I’m missing something, this doesn’t work. The issue is that the parser cannot find a person understood as “Mrs. Whip” in the scope of the player. That triggers the parser error. Changing the definition of the giving it to action to refer to “any person” causes the action to fail the basic accessibility rule. The response becomes “You can’t reach into the {location of Mrs Whip}.” That means you have to turn off the basic accessibility rule for the action. Then, of course, you have to write a rule to handle giving Mrs. Whip something when she’s not there.

Example:

The Florist is a woman in the Flower Shop.

Instead of giving something to the Florist:
	say "She waves her hand and says: 'No, no, sir. You[']ve already paid for them.'"

The clump of flowers is a thing carried by the player. Understand "clump" or "flowers" as the clump of flowers.

The Street Corner is south of the Flower Shop. "This is a street corner."

Mrs Whip is a woman in the Street Corner. Understand "missus/mrs/ms/-- whip" as Mrs Whip.

[These lines will override the syntax defined in the standard rules.]
Understand "give [something preferably held] to [any person]" as giving it to.
Understand "give [any person] [something preferably held]" as giving it to (with nouns reversed).

[This line turns the accessibility rule off.]
The basic accessibility rule does nothing when the current action is giving.

[This line provides a response specific to Mrs Whip, but only when she's not visible.]
Instead of giving something to Mrs Whip when Mrs Whip is not visible:
	say "Mrs. Whip isn't here to accept your gift."

Test one with "i/x florist/give florist flowers/x mrs whip/give flowers to mrs whip".

1 Like

That’s why you need a new action with the other grammar—one that doesn’t require touchability, and doesn’t do anything to the character except say they’re not here.

I tried your suggestion:

Understand "give [something preferably held] to [any person]" as gifting it to.
Gifting it to is an action applying to two things.

This solves the can’t find any such thing problem by placing every person object partially in scope–the player can reference any person in the command. However, a person object that isn’t in the location is not accessible, so you get an error that you can’t reach into the location of the referenced person. Turning that rule off for the action solves that problem.
Then you can provide a check rule:

Check an actor gifting something to (this is the can't give things to people who aren't there rule):
	if the second noun is not visible:
		say "[The second noun] is not here at the moment.";
		stop the action.

You don’t have to create a new action. If you change the existing action, you only need to write the specific rules you need.

1 Like

This is because you’ve specified that the person involved must be touchable (the default) in your action definition.

Gifting it to is an action applying to one touchable thing and one visible thing.

removes this requirement, so the problematic basic accessibility rule doesn’t apply.

Alternatively, catching the action not in a Check rule but in a Before rule (which runs before the basic accessibility rule) also avoids the problem.

1 Like

This is a deliberate convention of IF, the cryptic ‘You can’t see any such thing’ being shorthand for ‘You can’t refer to anything with the name you just typed right now, but I’m not letting on whether that’s because such a thing exists but you can’t see or sense it right now, or because such a thing doesn’t exist at all.’

This is to avoid players typing ‘take sword’ and being able to tell simply from the response whether there is a sword somewhere in the game.

If you want “I don’t see them here” as a response to “give flowers to Mrs bgytddb” then you’ll need something even more generic than an action that responds to any person, because of course ‘Mrs bgytddb’ is not the name of a thing anywhere in the world, so will still invoke a ‘You can’t see any such thing’ response.

1 Like

The problem with the

Understand "give [something preferably held] to [any person]" as gifting it to.

approach is that the compiler gives this grammar line higher priority than the standard “give [something preferably held] to [someone]”, so trying to give something to someone in scope will still become gifting it to rather than giving it to.

The following takes this awkward circumstance into account:

Gifting it to is an action applying to one touchable thing and one visible thing.
Understand "give [something preferably held] to [any person]" as gifting it to.
Before gifting something to in the presence of the second noun:
	try giving the noun to the second noun instead. [diverts gifting to giving if the recipient is in scope]
Before gifting:
	say "You don't see anyone of that name.". [default response if recipient is not in scope]

To catch the case where the recipient doesn’t exist, you can use the catch-all:

Understand "give [something preferably held] to [text]" as a mistake ("You don't see anyone of that name."). [default response if recipient does not exist]

Note that this setup allows different responses to the case where the recipient exists but is just not in scope and the case where the recipient simply doesn’t exist.

If that’s not important, you can completely dispense with the gifting it to action and just go with the ‘Understand “give … [text]” as a mistake’ approach, which will always be given lowest priority as a grammar response to the give command, and will therefore ultimately catch all commands starting ‘give <something> to…’ where the recipient is invalid.

EDIT: You can see the grammar line priorities by typing ‘showverb give’, which with the above setup yields:

>showverb give
Verb ‘feed’ ‘give’ ‘offer’ ‘pay’
* creature held → Give reverse
* held ‘to’ scope=Routine(221423) → A_gifting_it_to
* held ‘to’ creature → Give
* Routine(1618) held ‘to’ topic → MistakeAction

* held 'to' scope=Routine(221423) -> A_gifting_it_to

is the I6 equivalent of

Understand "give [something preferably held] to [any person]" as gifting it to.

where
* means ‘match any one of the Verb words listed above here’
scope=Routine(221423) means “[any person]”

* held 'to' creature -> Give
is the I6 equivalent of the standard

Understand "give [something preferably held] to [someone]” as giving it to.

Note that inspecting the grammar for ‘give’ reminds us that there is an alternative way to phrase ‘give the flowers to Mrs Whip’ which is ‘give Mrs Whip the flowers’, which would be matched by the first grammar line
* creature held -> Give reverse
We can include this possibility in our setup by adding:

Understand "give [any person][something preferably held]" as gifting it to (with nouns reversed).
Understand "give [text]" as a mistake ("You don't see anyone of that name.").
3 Likes