Can pcall return value of called function instead of boolean result true/false?
for example
function f()
return 'some text'
end
print(tostring(pcall(f)))
print will show only true or false instead of value returned by f
tostring selects only first parameter.
a,b = pcall(f)
print(b) --> 'some text'
function f()
return 'some text'
end
local status, res = pcall(f)
if pcall() succeeded, status is true and res is the return value of f(). if pcall() failed, status is false and res is the error message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With