Is there anyway to input every values in a table as an argument?

For example, instead of listing every value here, I want to just casually put 1 argument for every values in the table.

local newCurve = bezier.new(points[1],points[2],points[3],points[4],points[5],points[6],points[7],points[8],points[9],points[10],points[11],points[12],points[13],points[14],points[15],points[16])

Sorry, I didn’t line them down since the W006 warning of script analysis

You can use a for loop and table.insert I believe,

local tables = {}
for i = 1, 16 do
  table.insert(tables, i, points[i])
end

Something like that I believe may work.

1 Like

Actually, that is a table already. All I want is to give everysingle values to as an argument
Using a loop won’t work, it would create 16 beziers because of 16 values in a loop
If you put it outside, then you need to do it casually again.

You can use the table.unpack(tbl) function to get the values of a table as a tuple:

local newCurve = bezier.new(table.unpack(points))

EDIT:
It’s worth mentioning that you will still have to catch these values with separate variables:

function bezier.new(val1, val2, val3, ...)
    -- ...
end

You could also recieve it using ... and put it back into a table but that’s just extra work to form a table.

It would be much easier for you to pass the whole table in the first place and change your function instead.

4 Likes