Saving Folders with their children

Hello, I am trying to create an inventory that saves players ‘Auras’. Each aura is it’s own folder with values inside that folder, What would be the best way about saving these folders. (There could be up to 250 in a players inventory at a time, also they may have multiple of the same aura so each aura has it’s own unique id)

I would use a 2-dimensional dictionary, for example the key could be the name and id (separated by underscore), and the values in an array like this:

local inventory = {
	["Green_14"] = { -- name and id
		1, 2, 3, '...' -- values
	},
	["Blue_4"] = {
		4,5,6, '...'
	},
	["Red_20"] = {
		7,8,9, '...'
	},
}

-- Getting a value from an aura

local auratype = 'Blue'
local id = 4
local index = 2 -- the second value in the aura folder

local key = auratype..'_'..tostring(id)

-- check if aura is in inventory

if inventory[key] then 
	print(inventory[key][index]) -- 5
end

Assuming, that you also wanna put this inside a datastore, I’d say this would work but be careful with those key/index values :sweat_smile:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.