Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

(SOLVED) How can I index to the table's name?

Asked by 5 years ago
Edited 5 years ago

In my script i am trying to sort animations into their intended tables. For it to work, i use the function string.find, to compare the tables string name and the animation name(i don't know if string.find will work yet, but that's not my current issue.) Is there a way to get the string name of a table without adding a child called "Name" to the table?

SOLUTION: Tables can't be named, so I just added a string called "Name" into the table.

local function Order(tabfolder,folder)
    for tabi,tabv in pairs(tabfolder) do
        for i,v in pairs(folder) do
            local anim = string.find(tabv.Name,v.Name)
            if anim then
                print("Instance "..v.Name.."is headed to "..tabv.Name)  
                table.insert(v,tabv)
            end 
        end
    end
end
0
You can index to create a table and key that you can reference elsewhere as a variable or value...but maybe I’m misreading your post? ABK2017 406 — 5y
0
can you explain "Is there a way to get the name of a table without adding a child to the table"? I might be misinterpreting this but you can't name tables, unless you are talking about the variable name theking48989987 2147 — 5y
0
yeah i did researching and discovered that, thanks for answering though BronzedMocha 60 — 5y
0
I know you solved it but just as note if you use [ ] to enclose a table key, then the key is the name. You just have to index the table rather than the value. [ ] will still get to the contents, but the string isn’t literal anymore for lack of a better word. ABK2017 406 — 5y

Answer this question