π Inventory
Very similar to the currency module, it's also programmed in a similar fashion.
Creating an inventoryβ
To create an inventory, do the following:
local Framework = require(path.to.framework).GetServer()
local Inventory = Framework.Inventory
Inventory.Create("RocketLaunchers")
Inventory.Finalise()
Modifying an Inventoryβ
To modify an inventory, you first need to get it.
-- again, assuming the player is defined.
local plrInv = Inventory.Get("RocketLaunchers", player)
BindToUpdateβ
Fires a BindableEvent whenever the inventory is updated.
plrInv:BindToUpdate(function()
print("Updated")
end)
GetStoredβ
Returns the players data, only use when initialising the data.
local data = plrInv:GetStored()
Getβ
Returns the players data, also.
local data = plrInv:Get()
Insertβ
Insert is like lua's table.insert, except its for inventories.
plrInv:Insert("AdminLauncher")
Addβ
This adds a dictionary into the inventory.
It takes two parameters:
- Key
- Data
plrInv:Add("AdminLauncher", {
Power = 100,
Cooldown = 10,
})
Editβ
Edits an existing key in the dictionary:
plrInv:Edit("AdminLauncher", {
Power = 500,
Cooldown = 5,
})
Removeβ
Removes a value from the inventory.
plrInv:Remove("AdminLauncher")
HasItemsβ
Returns a boolean if the player has/hasn't got the item
local hasItem = plrInv:HasItem("AdminLauncher")
SearchItemβ
Searches for an item, used when searching for an item in an array instead of a dictionary.
plrInv:SearchItem("AdminLauncher")
Wipeβ
Wipes the inventory clean
plrInv:Wipe() -- :(