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

Inserting A Table Into A Dictonary?

Asked by
fff054 51
4 years ago

Hello Guys, Thank You For Clicking On My Question. As The Title Says, I've Been Searching How To Iterate Through A Table Tha's Into A Dictionary. I Know It's Possible Because I've Seen People Who Used This (The Owner Of Anime Fighting Simulator, For Example). So, I Tried Iterating With A For Loop, But It Was Kinda Weird And I Didn't Get What I Wanted.

So, If You Know How To Make So That You Can Iterate Through The Table That's Into The Dictionary, I Would Really Appreciate If You Put It Down In The Comments Section.

Example Of What I'm Trying To Do:

SabersConfig.Info = {
     ["A"] = {
        ['Name'] = 'Force Push';
        ['Power'] = ForcePush(); --That's A Function
        ['Key'] = "F";
        }   
}

0
:/ fff054 51 — 4y
0
52 views... :/ fff054 51 — 4y
0
I'm confused. Are you trying to iterate or insert? y3_th 176 — 4y
0
I'm trying to iterate through the Dictonary and get to the values like Name, Power And Key. fff054 51 — 4y
0
This is so sad :/ fff054 51 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

There are a couple of ways to iterate through a table.

The first way is a numerical for loop.

local Array = {1,2,3}

for i = 1, #Array do
    print(Array[i])
end

The other way is to use a pairs loop.

local Dictionary = {
    A = "B",
    C = "D",
}

for i,v in pairs(Dictionary) do
    print(i, v)
end
0
Uh, I think you misunderstood me. What I was looking for ways to Iterate through a table that's into a Dictionary, As the example shown above. fff054 51 — 4y
0
You'd do the same thing I just did inside another for loop with the other table you want. Risa_Azumi 13 — 4y
0
Oh, Right. Thank You So Much! fff054 51 — 4y
Ad

Answer this question