I'm working on making a 2D tile-based game, and I believe that storing Vector2's in a table to find the information of a tile would be quite useful. To explain better, this is what I'm trying to do:
local worldData = { tiles = { Vector2.new(0, 1) = "wall" } }
I've tried both without and with the '.new', but to no success. The wiki explains that "both the key and value can be any Lua value (numbers, strings, Parts etc., and even other tables) except nil." Sadly the wiki does not provide any example of setting the key to a data type besides a string and integer.
As a side question, I've also noticed that you can't manually add in a Vector2, along with many other values, to objects in Roblox Studio's explorer. Any way to do that?
As you probably know, you can use strings as a key in dictionaries either with the notation
{field = 4}
or {["field"] = 4}
. Every other data type will need to be wrapped in square brackets.
local worldData = { tiles = { [Vector2.new(0, 1)] = "wall" } }