Is it possible to make an key value pair, where the key is an array?

Tried finding an answer and couldn’t find one so sorry if it’s a repeat, but i’m trying to make a grid system and I wanted each coordinate pair in the table to have a value

function TileMap:Start()
	for x = 1, self.mapSizeX do
		for z = 1, self.mapSizeZ do
			local tile = findCoordinate(self.tiles, {x, z})
			table.insert(self.tiles, {x, z})
		end
	end
	print(self.tiles)
end

This prints out [key] = {x, y} (256 = {16, 16} for example), but what i’m trying to have it print {x, y} = 1 (so now the array is the key and i can change it’s value by just finding the coordinates on the grid). Is this possible or is there an easier/different way to go about this
image

You can turn the coordinates into a string, since that uniquely encodes every coordinate. So for X = 10 Y = 20 the key could be like “10,20”

2 Likes

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