local K={}function K.new()return setmetatable({},{__index=function(V,S)if K[S]then return K[S]end local e={}V[S]=e setmetatable(e,{__index=function(K,V)local S={}e[V]=S return S end})return e end})end function K.addCell(I,K,V,S,e)e.grid=I I[K][V][S]=e end return K
--Generates a table type that can be indexed in 3 dimensions by creating a new table if one doesn't exist for the x and y dimensions
local VolumeGrid = {}

function VolumeGrid.new()
	return setmetatable({}, {
		__index = function(grid, x)
			--return the grid class method if it exists
			if VolumeGrid[x] then
				return VolumeGrid[x]
			end
			
			local row = {}		
			grid[x] = row
			
			setmetatable(row, {
				__index = function(_, y)
					local column = {}
					row[y] = column
					
					return column
				end
			})
			
			return row
		end
	})
end

function VolumeGrid:addCell(x,y,z, cell)
	cell.grid = self
	self[x][y][z] = cell
end

return VolumeGrid