This here is a function that does something. I have been trying to write out what it does and I couldn’t figure out what line 10 and 15 does. I know that it adds something into a table but how.
01 | CreateConfiguration = ( function (Configurations, Table) |
02 | --gets the table of the first parameter |
03 | print (Table) |
04 | for i, v in pairs (Configurations:GetChildren()) do |
05 | print (Table) |
06 | --finds if the values classname is a value |
07 | if string.find(v.ClassName, "Value" ) then |
08 | --if it make its name a clone of its value |
09 | print (Table) |
10 | Table [ v.Name ] = v:Clone() |
11 | --if it isnt and it is either a folder or configuration class |
12 | print (Table) |
13 | elseif v:IsA( "Folder" ) or v:IsA( "Configuration" ) then |
14 | --then make the values name become |
15 | Table [ v.Name ] = Functions.CreateConfiguration(v, Table) |
1 | The parameter configurations is a folder containing different value types for a gun. |
the Table parameter is just an empty table that gets filled up. I wanna know how it is getting filled up what confuses me is that it goes to the spot in the table getting the current value being cycled throughs name but that line itself adds it to the table.
I suppose the question is asking how the table is being filled up, so that’s what I will attempt to answer, correct me if I got the question or even my answer wrong.
Things can be inserted into a table a couple of ways:
01 | --You can set everything in place manually: |
02 | local array = { 1 , true , "yes" } |
03 | local dictionary = { |
04 | [ "Test" ] = 1 , |
05 | [ "Test2" ] = true , |
06 | [ "Test3" ] = "yes" |
07 | } |
08 |
09 | --You can do table.insert |
10 | local array = { } |
11 | table.insert(array, "yes" ) |
12 | --printing the table out will show "yes" in it |
13 |
14 | --Annd you can do this: |
15 | local dictionary = { } |
16 | dictionary [ "Test" ] = 1 |
17 | dictionary [ "Test2" ] = true |
18 | dictionary [ "Test3" ] = "yes" |
19 | --Printing this dictionary will have the same result with printing the first dictionary |
hey you! have you ever heard of enes? if you are in trouble, better call enes!