Skip to content
This repository was archived by the owner on Apr 19, 2025. It is now read-only.

fix(server/inventory): CanCarryItem returning false where an item should be able stack. #1907

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gamenew09
Copy link

Fixes #1906


Essentially when an inventory is full of items, when you try and check if you can add a stackable item that is in the inventory using CanCarryItem, it returns false. It seemed to stem from the strict metadata check.

When the metadata value is nil in CanCarryItem, the metadata table created is { type = nil }. Lua treats that new table as a hashmap even though it's really just an empty table (at least table.type looks at the table like that), and it seems to break the strict metadata check.

@gamenew09
Copy link
Author

Hopefully I explained it well, my explaining skills are not the best haha

local md
if type(metadata) == 'table' then
md = metadata
elseif type(metadata) == 'string' then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type value of metadata can be of any type, it doesn't have to be a string. I believe checking if metadata is not nil here is the better check

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CanCarryItem doesn't seem to properly handle when metadata is nil
2 participants