It would be easy if it just would be basic calls like
assert( 1 == 2, "one is not equal to two!", 0 )
But what really makes this troublesome is when you try to use functions that return multiple values, because if you use an error message and/or level then it only returns one value, that is, if the condition is true ofcourse, like in this example, where you can see the difference when only supplying the first argument( condition ) versus supplying all the arguments( condition, message, level ).
--# Without error level
local args = { assert_level( foo( true ) ) }
print( unpack( args ) ) --# Output: bar
--# With error message and level
local args = { assert_level( foo( true ), "failed to get values", 2 ) }
print( unpack( args ) ) --# Output: b failed to get values 2
I've figured out that's because when you pass a function call as the first argument, and it returns more than one value, those values gets overwritten by the arguments message and level that you pass onto the assert_level function, but I still haven't figured out how to solve this( if it's even possible )
The code I'm using
So I'm basically wondering, is there a way to make this work? Or have I come to a dead end?











