Omitting an item from inventory

The player has jerky, but when he eats it, it still shows up in the inventory. I would like it to disappear. I assumed that since ‘eating something’ was in the extension rules, it would automatically go nowhere, or not be displayed. I had a statement that said after eating it was nowhere, but then I got ‘no such thing’ kind of error instead of ‘you already ate that’.

Jerky is a thing that is edible. Jerky is either eaten or not eaten.  Jerky is not eaten.
Description of jerky is "Jerky is dried meat that is nutrious but not all that tasty."
Understand "snack" as jerky.
Instead of examining jerky when jerky is eaten, say "You already ate it!".
Instead of eating jerky:
	say "Hmm. Not too bad.";
	now jerky is eaten.
Rule for printing the name of jerky when jerky is eaten: say "No jerky left.".

Saying ‘no jerky left’ is my workaround for the inventory command, but that is rather lame. Does someone understand how to make an item disappear from inventory?

“Now the jerky is nowhere” will work.

1 Like

Carrying out eating normally moves something to nowhere. You’re blocking that by using an Instead rule that causes the Carry Out rule to never be reached. This is all you need:

Jerky is an edible thing.
Report eating jerky:
	say "Hmm. Not too bad."; stop the action.

(Well, you’d need more if you really want the “You already ate it!” message instead of just “You can’t see any such thing.”)

2 Likes

How is that different from “remove jerky from play”? I haven’t seen any difference between these, but is there an under-the-hood reason to use one instead of the other in any given scenario?

The biggest difference is that if you’ve said Use no deprecated features you couldn’t compile remove jerky from play 'cause it’s formally deprecated, i.e., we have forewarning to not expect it to work at all in the next release of I7. They’re not literally the same code under the hood, but they’re equivalent

2 Likes
Check eating jerky when the jerky is off-stage:
     say "You already ate it. It was tasty." instead.
1 Like

Mike,
Thanks for the idea, but jerky nowhere means the noun is not found, and examining gives the error msg that you can’t see any such thing.

Zed,
Stop the action still causes the jerky to show up in inventory.

You still have an instead of eating the jerky rule?

Zed,
Interesting. Player is riding a horse, so when Report eating jerky occurs, it objects because the horse wouldn’t appreciate it. Not sure why that happens, but it still shows up in inventory of the horse. ?!

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".
2 Likes

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

3 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