Custom Inventory

If you use an inventory that is not supported out of the box, set Config.Inventory = "custom" and fill in the stub files.


Setup

-- editable/shared/config.lua
Config.Inventory = "custom"

Two stub files are then loaded automatically:

File
Side

editable/custom/inventory_server.lua

Server

editable/custom/inventory_client.lua

Client


Server Stubs

Open editable/custom/inventory_server.lua and implement each function:

CustomInventory.Server = {}

-- Add `count` of `name` to the player's inventory.
-- metadata and slot are optional.
-- Return true on success.
CustomInventory.Server.AddItem = function(src, name, count, metadata, slot)
    return false
end

-- Remove `count` of `name` from the player's inventory.
-- Return true on success.
CustomInventory.Server.RemoveItem = function(src, name, count, metadata, slot)
    return false
end

-- Return the total count of `name` in the player's inventory.
CustomInventory.Server.GetItemCount = function(src, name, metadata)
    return 0
end

-- Return the full inventory as { [itemName] = count }.
CustomInventory.Server.GetItems = function(src)
    return {}
end

Client Stubs

Open editable/custom/inventory_client.lua and implement each function:


Example

Once implemented, all standard koja-lib inventory calls route through your functions:

Last updated