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.

CreateConfiguration = (function(Configurations, Table)
        --gets the table of the first parameter
        print(Table)
        for i, v in pairs(Configurations:GetChildren()) do
            print(Table)
            --finds if the values classname is a value
            if string.find(v.ClassName, "Value") then
                --if it make its name a clone of its value
                print(Table)
                Table[v.Name] = v:Clone()
                --if it isnt and it is either a folder or configuration class 
                print(Table)
            elseif v:IsA("Folder") or v:IsA("Configuration") then
                --then make the values name become
                Table[v.Name] = Functions.CreateConfiguration(v, Table)
            end
            print(Table)
        end

        return Table
    end),

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.

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:

--You can set everything in place manually:
local array = {1, true, "yes"}
local dictionary = {
    ["Test"] = 1,
    ["Test2"] = true,
    ["Test3"] = "yes"
}

--You can do table.insert
local array = {}
table.insert(array, "yes")
--printing the table out will show "yes" in it

--Annd you can do this:
local dictionary = {}
dictionary["Test"] = 1
dictionary["Test2"] = true
dictionary["Test3"] = "yes"
--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