Show number of items carried and max inform 7

me again i have looked and can’t find how to write this. I want a counter telling player number of items they have and the max they can carry? sorry to bother you guys but i’m at a lost again :frowning:

It’s easy to change the status line to show how many items the player is carrying, out of a max number that you set. But you also have to police the limit during the game. I’ve done that at a very elementary level in this demo with a rule that runs ‘Before taking’. That doesn’t cover anomalous circumstances where code may try to put an item directly into the inventory (not via TAKE) but you have to deal with such things when and if they come up.

Have a look at ‘§8.3. Changing the status line’ in the docs for more detail on the status line element.

lab is a room.

an apple, banana, cherry, avocado, orange, mulberry, pineapple, watermelon, grapefruit, nectarine, plum, lettuce, grape are in lab.

max-items is initially 12.

Before taking something:
	if number of things carried by the player is at least max-items:
		instead say "Sorry, you can only carry [max-items in words] things at a time.";

When play begins:
	now the right hand status line is "[number of things carried by the player] / [max-items]";

Test me with "get all".

-Wade

1 Like

Thank you.

PS - You may also start wondering about things like, if the player’s wearing a hat, is that one of the things in the limit? What about in a backpack?

You’ll notice my code says ‘things carried by the player’. Carried is a particular definition, different to held, enclosed, and worn. I previously made a cheat sheet showing what items in what situations are scooped up by the different definitions:

-Wade

Actually, you can just set the carrying capacity of the player.

lab is a room.

an apple, banana, cherry, avocado, orange, mulberry, pineapple, watermelon, grapefruit, nectarine, plum, lettuce, grape are in lab.

The carrying capacity of the player is 12.

When play begins:
	now the right hand status line is "[number of things carried by the player] / [max-items]";

Test me with "get all".

That does exclude worn items. If you want to limit those as well you do have to get a little more complicated.

3 Likes