disambiguiating similarly named objects fully

Hello–

In the code below, I want to check for if something is in inventory, and use that, before attempting disambiguation.

I have used stuff like

does the player mean giving the grey shirt: it is likely

But

does the player mean giving a thing in inventory: it is likely

Doesn’t work. I think the error messages make sense to me.

It seems the “can’t give what you haven’t got” rule in Graham Nelson’s Standard Rules should apply first, too, but when I type “rules” and then “give white shirt to tex” the game says (first taking the white shirt) before getting to that rule.

So my question is twofold.

  1. how can I make it so “give red shirt” does not take the red shirt?
  2. how can I avoid the overgeneral disambiguation statement if you have 2 shirts?

I have a feeling I’m missing something very basic with rules–does anyone know how to make the can’t give what you haven’t got rule apply before we disambiguate or force taking?

Thanks to anyone who can help!

(note: edited as my first example(s) didn’t quite clarify things, even though I thought I checked it.)

[code]“shirts” by Andrew Schultz

The Hall of Too Many Shirts is a room.

The white shirt is a thing in the hall of shirts. The blue shirt is a thing in the hall of shirts. The grey shirt is a thing in the hall of shirts.

Tex is a man in the Hall of Too Many Shirts.

when play begins:
now the player is in the Hall of Too Many Shirts;
now the player has the grey shirt;

instead of wearing a shirt: say “This is a demo of something the author doesn’t understand in Inform, not an actual game.”;

test canttake with “give red shirt”;
test ambig with “give shirt/give blue shirt/give shirt”;
test donttake with “give blue shirt to tex”;[/code]

I’m not sure I understand your problem. Inform already automatically assumes that you want to give the grey shirt if you only have the grey shirt, doesn’t it? You don’t need a parser hint that states that the player is likely to mean something he carries, because that is already part of the way the parser behaves.

Perhaps your problem is that you want the disambiguation question to involve only held shirts when the player tries to give a shirt? I would strongly advise you against programming this. After all, the player might mean the shirt that is lying on the ground; and if we are asking a disambiguation question anyway, we should just ask the most helpful one possible.

What happens is this:

(1) The parser decides what the player means; if there is an ambiguity, the parser asks a disambiguation question. [Rules involving actions cannot run before this step is complete, because we don’t know which action will take place before the parser has decided this! So you could not possibly run the “can’t give what you haven’t got” rule before disambiguation.]
(2) Seeing that you can only give something that is held, Inform now tries the actor taking the noun.
(3) The check giving rules run, and the “can’t give what you haven’t got” rule fires if the noun is not held by the player character.

The “can’t give what you haven’t got” rule should fire when it does: we first try to help the player by using implicit taking, and we then only fail the action if the implicit taking didn’t work. If you want to get rid of implicit taking (something I should be wary of, because it is simply convenient for the player), you could kill it off entirely. I’d have to think about how you could that, though.

Victor,

Sorry for the delay in replying. I forgot to check the ‘notify me’ box.

I think I understand what you are saying, and it makes sense in general. This isn’t a huge deal, and I had a go at overturning, implicitly taking stuff, but that makes a lot more problems.

It’s frustrating for me when I ask a question like this that I think could be important and it isn’t. So I appreciate your response very much. It makes a lot of sense & covers more ground than what I asked, which helps the whole learning thing.

Glad I could be of help. :slight_smile: