I have a table logTable = {["cdm"] = "log text", ["data_engine"] = "log text"}
The code:
for k,v in pairs(logTable) do
print(v["cdm"]) end
Gives the desired result: log text
However
print(logTable["cdm"])
returns nothing. What am I doing wrong here?
EDIT:
So this is actually how I am making the table:
table.insert(logTable, { [probeName] = file.read('export/'..robotName..'/probes/'..probeGroup..'/'..probeName..'/'..probeName..'.log')})
Where probeName is a variable, could it be that I need to ["probeName"] to make it a string? However this takes it as a literal and not a variable?
How can I use a variable as table index/key