Originally Posted by Baertram
For me it looks that your function GetSearchResults() will build up a new table with the values of ALL your textues and paths that match to the searched string.
|
Yes that is what it does.
Originally Posted by Baertram
But you'll build a table "searchResults " with non-digit keys here!
Or does your table TEXTUREIT_TEXTURES store the key as digits? It looks like you are using text "name of texture" = texture "path to texture"?
|
TEXTUREIT_TEXTURES -- does not store its elements with numeric keys. Yes (ignoring all of the tables inside it, it does eventually come down to) textureName = texturePath
But that doesn't matter because searchResults has numeric keys, everything that gets put into the searchResults table is inserted with:
Lua Code:
-- destTable is the searchResults table
table.insert(destTable, {["text"] = key, ["texturePath"] = value})
and the table.insert function automatically handles the positioning of entries into the table and it inserts them with numeric keys.
So for example:
Lua Code:
local temp = {}
table.insert(temp, {...somestuff...})
table.insert(temp, {...someOtherStuff...})
-- would give us:
temp = {
[1] = {...somestuff...}
[2] = {...someOtherStuff...},
}
EDIT: By the way, just incase I had missed something & something was getting added to the table without a numeric key I did check it.
That is why I added the line:
Lua Code:
someTempTable = searchResults
So that when the error occurred I could /zgoo someTempTable & make sure that all entries were stored with numeric keys & that no entries were missing. Everything looked ok.