Appearance
K.Inventory
Functions
K.Inventory.Create
lua
K.Inventory.Create( name: string, options: { Slots: number?, Saved: boolean?, ClientCanUse: boolean?, ClientCanMove: boolean? }? ): InventoryServer: creates an inventory every player gets their own copy of. Options: Slots (max stacks, default 500), Saved (true), ClientCanUse / ClientCanMove (false): let players use or rearrange items from a LocalScript.
K.Inventory.Get
lua
K.Inventory.Get(name: string): InventoryServer: the inventory created with this name. Client: a read-only view of yours.
K.Inventory.Names
lua
K.Inventory.Names(): { string }K.Inventory.Default
lua
K.Inventory.Default(): InventoryServer: the first inventory created; used when an inventory isn't named.
K.Inventory.Transfer
lua
K.Inventory.Transfer(player: Player, from: any, to: any, slot: number, amount: number?): (boolean, string?)Server: moves the stack in slot (or amount of it) from one inventory to another. All or nothing; item data travels with it. Runs both inventories' Remove and Add hooks.
Methods on inventory
inventory:Add
lua
inventory:Add( inventory: InventoryData, player: Player, item: string, amount: number?, data: { [string]: any }?, source: string? )inventory:Remove
lua
inventory:Remove(player: Player, item: string, amount: number?, source: string?)inventory:Use
lua
inventory:Use(player: Player, slot: number, source: string?)Runs the item's OnUse for the stack in slot.
inventory:Move
lua
inventory:Move(player: Player, from: number, to: number, source: string?)Swaps two slots, or merges them when they hold the same stackable item.
inventory:Count
lua
inventory:Count(player: Player, item: string): numberinventory:Has
lua
inventory:Has(player: Player, item: string, amount: number?): booleaninventory:Fits
lua
inventory:Fits(player: Player, items: { [string]: number }): booleanTrue if all of these items fit at the same time, e.g. Backpack:Fits(player, { Apple = 3, Sword = 1 }).
inventory:Get
lua
inventory:Get(player: Player): { Stack }A copy of the player's stacks. Change the inventory with Add/Remove/Move, not the copy.
inventory:Clear
lua
inventory:Clear(player: Player)Removes everything (skips hooks).
inventory:OnChanged
lua
inventory:OnChanged(callback: (Player) -> ())Runs callback(player) after any change to a player's copy of this inventory.
inventory:Before
lua
inventory:Before(operation: string, callback: (Context) -> (), priority: number?)Hooks, like K.Currency's: change ctx fields or ctx:Cancel("reason").
inventory:After
lua
inventory:After(operation: string, callback: (Context) -> ())inventory:Middleware
lua
inventory:Middleware(operation: string, callback: (Context, () -> ()) -> (), priority: number?)Full middleware: callback(ctx, next). Call next() to continue.
inventory:Override
lua
inventory:Override(operation: string, callback: (Context) -> boolean?)Replaces an operation's core (advanced). Return false to fail.
inventory:Get
lua
inventory:Get(): { Stack }inventory:Count
lua
inventory:Count(item: string): numberinventory:Has
lua
inventory:Has(item: string, amount: number?): booleaninventory:OnChanged
lua
inventory:OnChanged(callback: ({ Stack }) -> ())Runs callback(stacks) now and after every change.
inventory:Use
lua
inventory:Use(slot: number)Asks the server to use the item in slot (the server must allow it with ClientCanUse).
inventory:Move
lua
inventory:Move(from: number, to: number)Asks the server to move a stack (the server must allow it with ClientCanMove).
Generated from
src/Corode/Inventory.luau.
