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

Why does this add something into a table (have to say extra to post) for the time element of y?

Asked by 2 years ago

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.

01CreateConfiguration = (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)
View all 21 lines...
1The 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.

0
What is this script from, if you don't know what it does it sounds like a free model script which is stated in the website guidelines to not post for us to fix. Protogen_Dev 268 — 2y
0
I don’t want you to fix it cause it works santafatso28 4 — 2y
0
I want you to tell me why it works. I am using this model as an example for what I do and don’t understand. santafatso28 4 — 2y
0
I wanna know why it works so I can do something like it myself and not just copy other peoples work santafatso28 4 — 2y

2 answers

Log in to vote
0
Answered by 2 years ago

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:
02local array = {1, true, "yes"}
03local dictionary = {
04    ["Test"] = 1,
05    ["Test2"] = true,
06    ["Test3"] = "yes"
07}
08 
09--You can do table.insert
10local array = {}
11table.insert(array, "yes")
12--printing the table out will show "yes" in it
13 
14--Annd you can do this:
15local dictionary = {}
16dictionary["Test"] = 1
17dictionary["Test2"] = true
18dictionary["Test3"] = "yes"
19--Printing this dictionary will have the same result with printing the first dictionary
Ad
Log in to vote
-1
Answered by
enes223 327 Moderation Voter
2 years ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

Answer this question