Current Version: V.1.0 BETA (07/13/2021)
This is my first post in addition to my portfolio on the forum, constructive criticism is always welcome!
Notable Features
-
Centralized State
-
Absolute control over your tool/inventory objects
-
Easy to grasp and intuitive structure
-
No credits necessary and full help support available!
Introduction
Developers like having absolute control over important aspects of their games which is why I think this system can be a convenient resource. ‘Tools’ and ‘Inventories’ are treated as objects. Each tool is a class extending from the ‘Base’ class that defines some essential events and utilities. The inventory object houses all the tool objects inside it, the client has a copy of its inventory which is kept up-to-date with its server-side counterpart.
https://www.roblox.com/library/7085536353/Inventory-System-1-0-BETA
Package.rbxm (15.3 KB)
OR
Direct download
Inventory-System-1-0-BETA.rbxl (173.9 KB)
How To Use
This is how things are set-up:
Server Inventory System Tool System Tools <classes> ToolBase <class> Inventory System InventoryBase <class> InventoryService Client Inventory System Tool System Tools <classes> ToolBase <class> Inventory System InventoryBase <class>
To get started, clone the ‘ExampleTool’ module found in the ‘Tools’ folder and start writing your functionality in the ‘Init’ function. To modify what Tools are given when a player spawns, open the ‘InventoryService’ module and edit the ‘StarterPack’ table. More settings for inventories can be configured in the ‘InventoryBase’ module.
Let me know what you think, and please don’t hesitate to post your creations using this module in the replies below!
Click here to read the API
API
InventoryObject InventoryBase.new(Player player)
Creates and returns a new inventory object for the specified player
array InventoryObject:GetClientData()
Returns an array of tools for use by the client
{
{
ID = number, Name = string, Key = string, Storage = boolean } > Key is the KeyCode this tool is equipped/unequipped if it’s in the hotbar. Storage is false if the tool is in the hotbar, false if it’s in ‘Storage’
},
…
}
number InventoryObject:AddTool(string toolName)
Adds the tool with the specified name to the inventory and returns the added tool’s ID, the Init function of the new tool object is called after it’s added to the inventory
void InventoryObject:RemoveTool(number toolId)
Removes the tool with the specified id, the Destroy function of the found tool is called before it’s removed from the inventory
void InventoryObject:MoveTools(number fromId, number toId)
Swaps the position of the tools with the specified ids
void InventoryObject:EquipTool(string key)
Equips the tool with the specified equip/unequip key, Equipped event of the tool object is fired
void InventoryObject:UnequipTool()
Unequips the currently equipped tool, Unequipped event of the tool object is fired
void InventoryObject:ActivateTool()
Activates the currently equipped tool, Activated event of the tool object is fired
ToolObject ToolBase.new()
Creates and returns a new tool object
Signal ToolObject.Equipped
Fired when the tool is equipped
Signal ToolObject.Unequipped
Fired when the tool is unequipped
Signal ToolObject.Activated
Fired when the holder of the tool presses the LMB
Maid ToolObject.Maid
A utility object for keeping track of cleaning script connections.
void ToolObject:Init()
This function must be present in your tool classes, it is called after the tool is added to an inventory
void ToolObject:Destroy()
This function must be present in your tool classes, it is called before the tool is removed from an inventory
Update Log
Current Version V.1.0 BETA (07/13/2021)
- Features listed above