Override Inventory Stacking
Use the Overrides system to change how items stack in shiva-inventory — without touching the module's source code.
The Problem
By default, shiva-inventory stacks items of the same type. You want a specific item (e.g. unique_ring) to never stack — each one should be a separate slot.
Solution: Plugin Hook
shiva-inventory exposes an inventory:beforeStack plugin hook. Return false to prevent stacking.
Step 1 — Create a Module for Overrides
bash
shiva make module my-overridesStep 2 — Register the Plugin
lua
-- server/init.lua
local M = {}
local NON_STACKABLE = {
unique_ring = true,
wedding_band = true,
rare_item = true,
}
function M.init(container)
container:bind('inventory:beforeStack', function(ctx)
if NON_STACKABLE[ctx.item] then
return false -- prevent stacking
end
return true
end)
end
return MStep 3 — Add to server.cfg
ini
ensure my-overridesThat's It
No forks, no edits to shiva-inventory. When shiva-inventory updates, your override continues to work.
Going Further
This same pattern works for:
- Blocking certain items from being added at all
- Adding weight limits different from the global default
- Custom stacking logic based on item metadata
See Concepts: Overrides → for all five override levels.