So when the Vector3 value is within the table, you call it just like you would any other value:
MyTable = {}
MyTable.Example1 = 123456789
MyTable.Example2 = Vector3(123, 456, 789)
print(MyTable.Example1) -- Returns 123456789 (Int)
print(MyTable.Example2) -- Returns Vector3(123, 456, 789) (Vector3)
print(MyTable.Example2.x) -- Returns 123 (Int)
print(MyTable.Example2.y) -- Returns 456 (Int)
print(MyTable.Example2.z) -- Returns 789 (Int)
You can access the z, y, z of Vector3 just by calling like I did above; think of it like a table within a table, if you will.
So the way you access it really depends on the way you store it in the first place, and there a few different ways of doing that. Below is the same data, written a few different ways:
MyTable = {}
table.insert(MyTable, {Name = "Coord 1", x = 0, y = 0, z = 0})
MyTable = {}
MyTable["Coord 1"] = {Name = "Coord 1", x = 0, y = 0, z = 0}
MyTable = {}
MyTable.Coord1 = {Name = "Coord 1", x = 0, y = 0, z = 0}
When storing your data, you need to pick the method that will be easiest to call from in the future, and by that I mean, for example, if all you need to do with the data later on is indiscriminately loop through it without needing to worry about any kind of identifier, then my table.insert will work fine for you, because to access that data specifically is a pain in the arse:
-- Normal looping
for _, Data in ipairs(MyTable) do
print(Data) -- Returns table (Table)
print(Data["Name"]) -- Returns Coord 1 (String)
print(Data["x"]) -- Returns 0 (Int)
print(Data["y"]) -- Returns 0 (Int)
print(Data["z"]) -- Returns 0 (Int)
end
-- Trying to find a specific entry
for _, Data in ipairs(MyTable) do
if Data["Name"] == "Coord 1" then
...
end
end
The reason you have to do it that way, is because the only identifying piece of information in the table, is the name value, however, it is just that, inside the table, so the only way to get to it is to access the table, either through a loop like above, or by accessing it’s specific table index, like so:
-- These are identical, and in this instance, interchangeable
print(MyTable[1]["Name"]) -- Returns Coord 1 (String)
print(MyTable[1].Name) -- Returns Coord 1 (String)
Like I said, this works just fine if you are, for example, just creating a bunch of blips on a map, and you could not care less about identifying information, however, if you do care about an identifier, you are best to store the data a bit differently. For example:
MyTable = {}
MyTable.MySpecificEntry = {x = 0, y = 0, z = 0}
print(MyTable.MySpecificEntry) -- Returns table (table)
print(MyTable.MySpecificEntry.x) -- Returns 0 (int)
print(MyTable.MySpecificEntry.y) -- Returns 0 (int)
print(MyTable.MySpecificEntry.z) -- Returns 0 (int)
The technical difference between this and the other example, is that while the Name value was unique, it was not the identifier of the entry, 1 would have been it’s identifier, since it was the first entry, whereas here, MySpecificEntry does not sit within the table itself, but rather it is the identifier of the table, so it can be accessed through MyTable.MySpecificEntry, whereas the other example cannot be.
If you want to do that, I would suggest using the blended table, and just putting the header in there as well, exactly as I have done in the working example I provided with Radius; just replace it with your heading value.
Sorry for any typos, not bothered to read through all this and fix them lol.
Not at all.