I’ve noticed that there are many inventory systems/resources in #resources:community-resources.
When I took a look at some of them, I realized that it was just plug-it-in and play. So I decided to make my own resource in order to give developers a better customizable alternative.
Why not use Satchel/NeoHotbar/other open-source inventory systems?
OpenInventory is not a complete inventory system. It’s just a backbone of an “inventory system”, which I made because of the unlimited possibilities instead of just a pre-made boundful system.
Features
Strictly Typed
Dynamic crafting
Easy Debug support
Stringified tables for memory efficiency
Optimized and secure API
How to setup
Get OpenInventory from the links above
Insert it into your game
Require the main module
Call Module:GetInventory(Player)
Optionally, use the provided Module.SaveFunction callback to add save functionality.
Hi,
In the docs, it has the comment
’ * Caution: if config.client_check is enabled, using the modules in a client environment will not work.’
When and how does this get enabled, and why would it be enabled or not enabled?
I hate to be a nuisance, but I seem to have run into another bug. For some reason whenever I use GetInventory() to create a new inventory instance, it ends up returning nil.
Here is my code:
-----------------
--//VARIABLES\\--
-----------------
--/Services\--
local ServerScriptServ = game:GetService("ServerScriptService")
local PlrServ = game:GetService("Players")
local RepStore = game:GetService("ReplicatedStorage")
--/Modules\--
local InventoryModule = require(ServerScriptServ:WaitForChild("OpenInventory"))
--/Other\--
local ItemsFolder = workspace:WaitForChild("Items")
local Event = RepStore:WaitForChild("RemoteEvent")
------------
--//MAIN\\--
------------
--On player join
PlrServ.PlayerAdded:Connect(function(Player)
local Inventory = InventoryModule:GetInventory(Player) --Create inventory (RETURNING NIL)
--On Item Pickup
for i, Item in pairs(ItemsFolder:GetChildren()) do --Loop through items that can be picked up
Item:FindFirstChildWhichIsA("ClickDetector").MouseClick:Connect(function() --Detect pickup
Inventory:AddItem(Item.Name, 1) --Adds item to inventory
Event:FireClient(Player, Item.Name, Inventory:GetQuantity(Item.Name)) --Updates inventory UI
end)
end
end)
I did some debugging and it is firing the function and creating the instance but for some reason isn’t returning it
My theory is that its an issue with this code:
function Module:GetInventory(Player: Player): (Player) -> Inventory
local target_inventory = self._manager[Player]
if target_inventory ~= nil then -- Checks if the target inventory is nil or not
return target_inventory -- If it's not, returns it
else
self._manager[Player] = newInventory(Player) -- If it is, generates a new one and appends it into the manager
end
return target_inventory
end
It seems that when the player has no inventory data it creates a fresh inventory instance but is still returning target_inventory which in that scenario would be nil
I could be wrong about this as I don’t fully understand how this module works but if I had to make a guess that’s what I’d say.
So sorry to keep bothering you.
thanks for the help
EDIT:
I made a small change to the module using my theory as to why it wasnt working and it seems to be working perfectly fine now. Here is the change I made:
Instead of having it return target_inventory I made it return self._manager[Player]
not sure if this effects anything but it seemed to fix it.
Can we get a full documentation? Specifically crafting because it is not well documented. From what I can tell you have to manually set every crafting recipe for new players. Would it be possible to just make a dictionary that the module uses to set the recipes to?