A list of helpful libraries and code

Simple just works object pooling function.

---Add objectToAdd into list
---@param list table table list
---@param objectToAdd table needs a "enabled" key
function ObjectPooling(list, objectToAdd)
	local found = false

	for i = 1, #list, 1 do
		local o = list[i]
		if not o.enabled then
			
			list[i] = objectToAdd
			found = true

			break
		end
	end

	if not found then
		list[#list+1] = objectToAdd
	end
end
2 Likes