The title explains it all
this:
local Dictionary = { ["value"], ["val"] = 1 }
does not work
any help is appreciated
If you mean something like this:
local dict = nil local Tab = {} dict = { ["a"] = 10, ["TabTest"] = Tab, ["b"] = function() return dict['a'] end, ["c"] = function() return dict["a"],dict["b"] end, ["CopyOfTabInDict"] = function() return dict["TabTest"] end } print(dict['b'](),dict['c'](),Tab,dict["TabTest"],dict["CopyOfTabInDict"]())
TabTest is Tab, CopyOfTabInDict returns TabTest with the exact same memory address.
Really the best thing other than that is to manually loop or index outside the dictionary like so:
local dict = {} dict.a = "hi" dict.b = dict.a print(dict.b)
or using a loop which would work too.
if you are aiming for something like this within a dictionary:
local a,b,c,d = 1,1,1,1
then you could make a function for it like this:
local dict = {} local function CreateMultiple(dictionary,value,...) local Variables = {...} for i, v in pairs(Variables) do dictionary[v] = value end end CreateMultiple(dict,10,"a","b","c","d") print(dict.a,dict.b,dict.c,dict.d,dict.e) -- dict.e is nil, the rest is 10
You could try to do stuff with metatables however, it might be hard.
in lua you cannot assign two things to the same value at once. best you can do is
value, val = 1, 1
. this applies to variables and dictionary keys, haven’t tested if the aforementioned method works for dicts though. either define them separately, or if you have a large amount, use a loop to fill them.