Asset System codereview

Hello this is a simple asset system library for my scripts to fetch all game assets, or find a specific asset. Using this for my shop system & avatar customization. Wondering how I can revamp this to be better.

local module = {}
local assets = {
	[1] = {
		AssetID = 1,
		ItemName = "Tactical Black Polo",
		Type = "Shirt",
		Creator = "5.11 TacticaI ®",
		Price = 100,
		IDs = {
			Shirt = 4967135460,
			Pants = nil,
			MeshID = nil,
			TextureID = nil
		}
	},
	[2] = {
		AssetID = 2,
		ItemName = "Levis Operator",
		Type = "Pants",
		Creator = "5.11 TacticaI ®",
		Price = 100,
		IDs = {
			Shirt = nil,
			Pants = 4849800396,
			MeshID = nil,
			TextureID = nil
		}
	},
}
function module:getAll()
	for i,v in pairs(assets) do
		print("asset found")
		if v.Type == "Shirt" then
			return false, v.IDs.Shirt, v.ItemName, v.Price, v.Creator
		end
		if v.Type == "Pants" then
			return false, v.IDs.Pants, v.ItemName, v.Price, v.Creator
		end
		if v.Type == "Mesh" then
			return true, v.IDs.MeshID, v.IDs.TextureID, v.ItemName, v.Price, v.Creator
		end
	end
end
function module:find(asset)
	for i,v in pairs(assets) do
		if asset == v.AssetID then
			print("asset found")
			if v.Type == "Shirt" then
				return false, v.IDs.Shirt, v.ItemName, v.Price, v.Creator
			end
			if v.Type == "Pants" then
				return false, v.IDs.Pants, v.ItemName, v.Price, v.Creator
			end
			if v.Type == "Mesh" then
				return true, v.IDs.MeshID, v.IDs.TextureID, v.ItemName, v.Price, v.Creator
			end
		end
	end
end
return module

If you want to take this to the next level, you can use an API to automatically get these items for you.

It’ll be much faster, and doesn’t require your details to be filled out each time something is uploaded

Custom names, custom creators, Some are required for meshids and meshtextures.

1 Like

What about putting those into the description?
It would look a bit odd but still work!