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

How do I print the contents of a function?

Asked by 6 years ago

I'm wondering whether or not its possible to print the unknown contents of a function. For example, if you have:

function aFunction(...)
    print(1)
end

How do I extract the line, "print(1)" from the function, so I can print it afterwards? Thank you in advance for your help.

1 answer

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
6 years ago

We can use variadic arguments, represented by '...' to help us with this

table1 = {}
function appendToTable(tab, ...)
    local args = {...}
    for i, v in pairs(args) do
        table.insert(tab, v)
    end
end
appendToTable(table1, "xD", ":D", "lol")

for _,v in pairs(table1) do
    print(v)
end

Source: Variadic arguments

Ad

Answer this question