A function that returns multiple results will return them separately, not as a table.
Lua resource on multiple results: https://www.lua.org/pil/5.1.html
You can do what you want like this:
t = {func1()} -- wrapping the output of the function into a table
print(t[1], t[2], t[3], t[4])
This method is will always get all of the output values.
This method can also be done using table.pack:
t = table.pack(func1())
print(t[1], t[2], t[3], t[4])
by using table.pack you can discard nil results. This is can be helpful to preserve a simple check of the number of results using the length operator #; however it comes at the cost of no longer preserving the result "order".
To explain further, if func1 instead returned 1, nil, 1, 1 with the first method you receive a table where t[2] == nil. with the table.pack variation you will get t[2] == 1.
Alternatively you can do this:
function func1()
return 1,1,1,1
end
t = {}
t[1], t[2], t[3], t[4] = func1() -- assigning each output of the function to a variable individually
print(t[1], t[2], t[3], t[4])
This method can allow you to pick and choose where outputs go or if you want to ignore one you can simply do:
t[1], _, t[3], t[4] = func1() -- skip the second value