The fl_inventory panel displays an inventory as a grid of fl_inventory_item slots and lets the player drag items around. It is created with Inventory:create_panel and is rebuilt every time the inventory is synchronized. Dropping an item onto a slot asks the server to move it there; dropping it onto the parent of the panel asks the server to drop it into the world. Pressing R rotates the item that is being dragged.

Summary

Methods

Sets whether the slots display their numbers.
Returns the icon that is drawn in the slots of the inventory.
Returns the inventory that the panel displays.
Returns the height of the inventory in a number of slots.
Returns the id of the inventory that the panel displays.
Returns the size of the inventory in a number of slots.
Returns the type of the inventory.
Returns the width of the inventory in a number of slots.
Returns the entity that the inventory belongs to.
Returns the instance ids of the items located in the specified slot of the inventory.
Returns the gap between the slots.
Returns the size of a single slot.
Returns the slots grid of the inventory.
Init()client
Creates the scrollable grid of slots and makes it accept dragged items.
Checks if the inventory is disabled.
Checks if the inventory is multislot.
Handles an item panel being dropped onto the inventory by asking the server to move its items to the hovered slot.
Rotates the item that is being dragged when R is pressed.
Draws the background of the inventory using the theme.
Draws over the inventory using the theme.
Resizes the scroll panels to fit the grid of slots.
rebuild()client
Recreates the slot panels based on the current contents of the inventory.
Sets the icon that is drawn in the slots of the inventory.
Sets the inventory that the panel displays and rebuilds the panel.
Sets the gap between the slots.
Sets the size of a single slot.
Resizes the panel so that all slots of the inventory fit in it.
Hides the item panel that is being dragged and puts empty slots in its place.

Methods

PANEL:draw_inventory_slots(bool)

client plugins/inventory/plugin/views/cl_inventory.lua:477

Sets whether the slots display their numbers. The value is stored on the panel under the name of this method, so the method cannot be called on the same panel again.

Parameters

  • bool Boolean

Returns the icon that is drawn in the slots of the inventory.

Returns

  • String FontAwesome icon id or path to a material, or nil if there is no icon

Returns the inventory that the panel displays.

Returns

  • Inventory

PANEL:get_inventory_height()

client plugins/inventory/plugin/views/cl_inventory.lua:413

Returns the height of the inventory in a number of slots.

Returns

  • Number

PANEL:get_inventory_id()

client plugins/inventory/plugin/views/cl_inventory.lua:401

Returns the id of the inventory that the panel displays.

Returns

  • Number

PANEL:get_inventory_size()

client plugins/inventory/plugin/views/cl_inventory.lua:419

Returns the size of the inventory in a number of slots.

Returns

  • Number width
  • Number height

PANEL:get_inventory_type()

client plugins/inventory/plugin/views/cl_inventory.lua:425

Returns the type of the inventory.

Returns

  • String

PANEL:get_inventory_width()

client plugins/inventory/plugin/views/cl_inventory.lua:407

Returns the width of the inventory in a number of slots.

Returns

  • Number

Returns the entity that the inventory belongs to.

Returns

  • Entity

Returns the instance ids of the items located in the specified slot of the inventory.

Parameters

  • x Number
  • y Number

Returns

  • List<Number> instance ids, or nil if the slot is out of the inventory bounds

PANEL:get_slot_padding()

client plugins/inventory/plugin/views/cl_inventory.lua:457

Returns the gap between the slots.

Returns

  • Number gap in pixels

Returns the size of a single slot.

Returns

  • Number size in pixels

Returns the slots grid of the inventory.

Returns

  • Map slots, indexed by y and then by x; every slot is an array of instance ids

Creates the scrollable grid of slots and makes it accept dragged items. Items dropped onto the parent panel get dropped into the world.

Checks if the inventory is disabled.

Returns

  • Boolean

Checks if the inventory is multislot.

Returns

  • Boolean

Handles an item panel being dropped onto the inventory by asking the server to move its items to the hovered slot. Holding CTRL moves half of the stack, SHIFT a single item.

Parameters

  • dropped Panel the fl_inventory_item panel that has been dropped

PANEL:OnKeyCodePressed(key)

client plugins/inventory/plugin/views/cl_inventory.lua:110

Rotates the item that is being dragged when R is pressed.

Parameters

  • key Number KEY_ enumerator

Draws the background of the inventory using the theme.

Parameters

  • w Number
  • h Number

Draws over the inventory using the theme.

Parameters

  • w Number
  • h Number

PANEL:PerformLayout(w, h)

client plugins/inventory/plugin/views/cl_inventory.lua:132

Resizes the scroll panels to fit the grid of slots.

Parameters

  • w Number
  • h Number

Recreates the slot panels based on the current contents of the inventory. Runs the 'OnInventoryRebuild' hook afterward.

Sets the icon that is drawn in the slots of the inventory.

Parameters

  • icon String FontAwesome icon id ('fa-...') or path to a material; nil for no icon

PANEL:set_inventory_id(inventory_id)

client plugins/inventory/plugin/views/cl_inventory.lua:278

Sets the inventory that the panel displays and rebuilds the panel.

Parameters

  • inventory_id Number id of the inventory

PANEL:set_slot_padding(padding)

client plugins/inventory/plugin/views/cl_inventory.lua:383

Sets the gap between the slots.

Parameters

  • padding Number gap in pixels

PANEL:set_slot_size(size)

client plugins/inventory/plugin/views/cl_inventory.lua:377

Sets the size of a single slot.

Parameters

  • size Number size in pixels

Resizes the panel so that all slots of the inventory fit in it.

PANEL:start_dragging(dropped)

client plugins/inventory/plugin/views/cl_inventory.lua:170

Hides the item panel that is being dragged and puts empty slots in its place.

Parameters

  • dropped Panel the fl_inventory_item panel that is being dragged

Defined in