Hello! It’s me again. I have been experimenting with tables and things like that again. Then I’ve found a function called table.find(). I’ve been trying that function, however, when I tried using it, some problems appeared.
To explain my problem I am gonna use an example:
local ThingsToPick = {
['1'] = {
'Food'
}
}
local Things = {
['Food'] = {
['Fruits'] = {
'Apple','Banana'
}
}
} --[[ This is where things are going to be listed in ]]
local function GetData(Input)
if table.find(Things,Input) ~= nil then
warn(Things[Input]['Fruits'][1])
-- The problem is that if I try using the word "Food" passed in the argument "Input", the table.find function will return as nil
end
end
GetData(ThingsToPick['1'][1])
You are using a dictionary, that is your first issue. It’s not even good practice to use strings instead of numbers anyways, because with numbers you can mark the table as an array. Use dictionaries if your index is not a number.
Secondly, table.find works only for one-dimensional arrays, in a sense, values directly under indexes.