Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Pocketing an object exceeds your inventory limit

A topic by Garry Francis created Sep 12, 2019 Views: 155 Replies: 11
Viewing posts 1 to 9
Submitted

I screwed my inventory down to a maximum of 5 items. This seemed like a reasonable limit for the number of objects and the size of the game. However, when I use :pocket "object"; it can easily exceed the limit. I found I was carrying 8 items when the limit was 5. What's going on here? Is this a bug/oversight or should I be doing something different to avoid exceeding the limit?

Host

Pocket should not ignore those limits, but I know that create does. Let me fix that for you.

Submitted

In the interim, I think I should test the number of items in the inventory prior to pocketing an item. If inventory is full, print the appropriate system message.

Host

I issued an update and re-documented the : pocket "" ; command.

https://adventuron.io/docs/tut/#_common_commands

"Creates an item and attempts to place it in the players pocket (or inventory) if there is enough space in the inventory (uses weight + item limits). If the player cannot take the object (too heavy or holding too many items), then the object is created in the location where the player is located when the location is redescribed or the prompt is redisplayed (whichever comes first).

If the object is placed in the inventory successfully, the operation will be quiet (no messages printed), if placing fails, then the appropriate error message (You're holding too many items, you're can't take that) will be displayed. Pocket should be the last item in an event loop, and should usually come after printing some message to describe the item that should be entering the inventory."

The logic as described above is failsafe logic, to prevent the game entering an unknown state. Usually dropping the object in the same room should be enough, but it may be that the : pocket "object_id"; is executed in a cut scene and coming back to the location where the object was dropped is no longer possible. Therefore it drops the untaken object in the location where the player has moved to (if the player has moved). 

Submitted

I think I'll do the manual test anyway, as I'm pocketing an item when removing it from a container and I don't want it to appear in the room if my inventory is full, as this implies that I've removed it from the container first, but I couldn't remove it from the container because my hands were full. Catch 22.

Er, did I explain that properly?

Host

Assuming weight is not an issue ...

   : if (items_carried () < carry_limit()) {
      : pocket "sword" ;
   }
Submitted

Exactly. And add appropriate text messages depending on whether test is true or false. Weight is not an issue.

Host

I will add a function (not in adventuron right now) called:

 can_carry "object_id"

A boolean function that will evaluate weight and item count for a proposed item to carry.

Host

I have now created this function as follows (in documentation now) :

is_pocketable "OBJECT_ID"

"Returns true if when hypothetically taking an object it would not exceed weight or item carry limits (to be taken). If the referenced item is held by the player, then this function will return true, and a subsequent call to ": pocket" will simply do nothing."

Submitted

Your example was wrong. I've used this:

         : if (num_items_carried() < inventory_item_limit()) {
            : pocket "object" ;
            : print "You take the object.";
         }
         : else {
            : print "You can't carry any more.";
         }

Host (1 edit)

Hi, this is actually the most valid code now (slight update to the API):

   : if (items_carried () < item_limit () ) {
      // TODO ::
   }
Submitted

OK. I reloaded the page and all my working code related to this was broken, so I've fixed it again.

Don't you love a moving target?