Omitting an item from inventory

Sorry, I might have misunderstood - are you saying want the jerky to still be around after it’s eaten so that the player can examine it whenever they want, just not have it be listed in inventory? If that’s what you’re after, you can try making the jerky part of the player in your instead of eating rule, though you’ll want to be careful about what you’re allowing the player to do with the nonexistent jerky (you might want a rule that redirects actions other than examining to examining while the jerky is part of the player, say). If that’s not what you’re trying to do, sorry, I’m even more muddled :slight_smile:

Mike,
I want to eat the jerky and have it removed from inventory. Unless I say ‘jerky is nowhere’, jerky is always in inventory. If I say ‘jerky is nowhere’, I cannot examine it later to say that it is already eaten. I have a horrible side effect too. In some cases, I get a blocking message: ‘horse would not appreciate that’ and ignores the jerky.In that case, jerky is still in inventory.

I’ve had this error before. With actions on:

> **eat jerky**
[eating jerky]
The fine quarterhorse might not appreciate that.
[eating jerky - failed the can't eat other people's food rule

Don’t know what the horse has to do with the jerky. It is on the player that is on the horse. If I successfully eat the jerky, it then is on the horse!

Ha. You found a bug.

Check an actor eating (this is the fixed can't eat other people's food rule):
  if the actor does not enclose the noun and the noun is enclosed by a person (called the owner) begin;
    if the actor is the player, say "[The owner] [might not appreciate] that.";
    stop the action;
  end if;

The fixed can't eat other people's food rule is listed instead of the can't eat other people's food rule in the check eating rules.
1 Like

Does this get you the behavior you want?


"Untitled"

Lab is a room.

The jerky is a thing that is edible. The jerky is in the lab.
The description of the jerky is "[if the jerky is part of the player]You already ate it![otherwise]Jerky is dried meat that is nutrious but not all that tasty."
Understand "snack" as jerky.
After eating jerky:
	say "Hmm. Not too bad.";
	now jerky is part of the player.

instead of doing anything other than examining to the jerky when the jerky is part of the player, try examining the jerky.

Zed is right that Instead rules applying to the built-in eating action are not the way to go here. You want to work with the eating action and allow the normal action to happen. And you want his replacement rule to fix the horse problem.

What you really seem to want is to be able to reference food items that aren’t “there” so that the player can get a custom response. That requires creation of a new action.

A thing can be eaten. [This defines the property for all things, not just the jerky.]

The player carries an edible thing called some beef jerky.

Carry out eating something (called snack) (this is the mark eaten things as eaten rule):
    now the snack is eaten. [All carry out rules will be executed by default, so this just works alongside the Standard Rules which remove eaten food from play.]

[Here's the fun part: A new action that uses the "eat" verb word but will be considered only after the normal eating action fails.]
Wishing for food is an action applying to one visible thing. Understand "eat [something eaten]" as wishing for food. [Note that "one visible thing" doesn't mean what it looks like it means.]

Check wishing for food (this is the notify that wished for food is eaten rule): [A check rule so that it is in an action-specific rulebook, with "instead" keyword so that the action registers as a failure. This could be an Instead rule if you like.]
    say "You already ate [the noun]." instead. [Works for any eaten food, not just the jerky.]

After deciding the scope of the player when wishing for food (this is the add previously eaten things to scope when wishing for food rule):
    repeat with memory running through eaten things:
	    place memory in scope. [This is what makes the eaten food "visible" for the purpose of the new action.]

Test me with "i / showme jerky / eat jerky / g / showme jerky".
1 Like

You can skip the scope manipulation if you use "eat [any eaten thing]".

2 Likes

I committed a version of Rideable Vehicles that includes an updated version of the rule above to the Friends repo.

MIke,
I don’t think so. ‘Examine jerky’ cannot find the noun. Doing anything to an absent noun gets me the default message. Making jerky part of a player seemed weird, so I made memory part of the player and put the jerky into memory (it was out of scope too, as desired) but ‘x jerky’ couldn’t find the noun.

otisdog,
That worked great! Thanks much!
I also learned another lesson: Earlier, I tried to make my own version of memory part of the player, so when I put the jerky into memory, it showed up in inventory except as *out of scope.
Things in this (built-in) memory doesn’t show up at all, which is better; unless I decide to allow the player to retain memory of things he once had or examined as he explores.

1 Like

Your new set of rules eating rules have been working great. Now however, after eating one of many things of food, I try ‘examine food’. It asks me which of the foods I want to examine, but it only proposes the *foods that already been eaten"! Example:

[7] x food
Which do you mean, apples, grapes, cheese, or slices of meat?
[8] x apples
Looks good enough to eat!
[9] x grapes
Looks good enough to eat!
[10] eat cheese
(first taking cheese)
You eat cheese. Not bad.
[11] eat meat
(first taking slices of meat)
You eat slices of meat. Not bad.
[12] x food
Which do you mean, cheese or slices of meat

I think I need to suppress an Examine rule, but not sure which one, or how. I don’t want to step on your “wishing for food rule”.

As far as I can tell, there really shouldn’t be any interaction between the code above and the examining action, so you shouldn’t have to worry about interference.

I’m not really sure what the problem might be. Perhaps you can try to strip things down to the minimum code that replicates the problem and post here?

1 Like

Besides the wishing for food rule you provided, I have added only this code.

Food is a kind of thing. Food can be eaten or not eaten. 
apples, grapes, cheese, and slices of meat are food.
apples, grapes, cheese, and slices of meat are edible.
apples, grapes, cheese, and slices of meat are in the dish.

[Without this line, parser doesn't see the object-noun "food"]
Understand "food" as some food.

Instead of examining food,
	say "Looks good enough to eat!";

I think that your memory trick brings the eaten back into scope so that ‘examine food’ sees it again. I don’t know why the uneaten food is not seen.

Could you please provide a whole code sample demonstrating this behavior?

This isn’t a fix for what you’re seeing, but instead of

I’d suggest:

The description of food is usually "Looks good enough to eat!".

It’s easy to overuse Instead rules. I wrote about when to use which action rulebooks elsewhere; here’s another post on the uses of action rulebooks by @HanonO. The perils of INSTEAD is a recurring topic here.

In my coding, Instead is the rulebook of last resort: if something can be straightforwardly accomplished with one of the other rulebooks, and there isn’t a particular reason why Instead is a better choice, I use the other rulebook. (This is a statement of personal preference and is more Instead-avoidant than the docs’ 12.21. Guidelines on how to write rules about actions themselves, which call for Check rules for general situations and Instead for specifics. So I’m not suggesting that my position is correct and anyone disagreeing with it is wrong; I’m just sharing my own thoughts.)

3 Likes

I used an equivalent description for food. The problem is that ‘x food’ provides a list of things 'eaten" instead of things not eaten. Here is the entire code.

[Special Eating rule so that player can examine jerky by mistake. --By otisdog from IF Forum
All carry out rules will be executed by default, so this just works alongside the Standard Rules which removes eaten food from play.]
Carry out eating something (called snack) (this is the mark eaten things as eaten rule):
    now the snack is eaten. 

[Here's the fun part: A new action that uses the "eat" verb word but will be considered only after the normal eating action fails.]
Wishing for food is an action applying to one visible thing. 
Understand "eat [something eaten]" as wishing for food. [Note that "one visible thing" doesn't mean what it looks like it means.]
Understand "examine [something eaten]" as wishing for food. 

[A check rule so that it is in an action-specific rulebook, with "instead" keyword so that the action registers as a failure. This could be an Instead rule if you like.]
Check wishing for food (this is the notify that wished for food is eaten rule): 
	say "You already ate the [noun]." instead. [Works for any eaten food, not just the jerky.]

After deciding the scope of the player when wishing for food (this is the add previously eaten things to scope when wishing for food rule):
	repeat with memory running through eaten things:
		place memory in scope. [This is what makes the eaten food "visible" for the purpose of the new action.]

Food is a kind of thing. Food can be eaten or not eaten. 
The description of food is usually "Looks good enough to eat!".
apples, grapes, cheese, and slices of meat are food that is edible.
apples, grapes, cheese, and slices of meat are not eaten.
apples, grapes, cheese, and slices of meat are in the dish.

[Without this line, parser doesn't see the object-noun "food"]
Understand "food" as some food.

Instead of

Understand "examine [something eaten]" as wishing for food.
Food can be eaten or not eaten.
Understand "food" as some food.

try

Food can be eaten or uneaten. 
Understand "food" as some uneaten food.

Parsing the player’s command works by the same principle as how Inform orders rules in rulebooks: more specific things are considered first. Because you said:

Understand "examine [something eaten]" as wishing for food. 

you’re telling Inform to preferentially interpret "examine " as the wishing for food action, and since “food” just meant any food, including eaten food, “examine food” implicitly became examining eaten food (if any eaten food exists).

2 Likes

Zed,
Thanks so much for explaining this. It was a big mystery to me. I will give that a try.

Zed,
I gave that a try and it worked! Thanks so much!
Is there a difference between ‘uneaten’ and ‘not eaten’?

Inform always understands “not foo” for binary properties, so you don’t have to name it.

Adding “uneaten” as a synonym just makes life easier.

1 Like

Andrew,
Thanks. I think I should have been clearer. If I say food is eaten or not eaten, but then say that an apple is uneaten, will the parser recognize the synonym?