diff --git a/src/luaopen/variant.cpp b/src/luaopen/variant.cpp index 7c1f4b1..39075d8 100644 --- a/src/luaopen/variant.cpp +++ b/src/luaopen/variant.cpp @@ -160,16 +160,14 @@ bool variant_is(const Variant& variant, const sol::stack_object& type) { return false; } -sol::stack_object variant__call(sol::this_state L, const Variant& variant, sol::variadic_args args) { - ERR_FAIL_COND_V_MSG( - variant.get_type() != Variant::CALLABLE, - to_lua(L, Variant()), - String("attempt to call a %s value") % get_type_name(variant) - ); - VariantArguments var_args = args; +sol::stack_object variant__call(sol::this_state state, const Variant& variant, sol::variadic_args args) { + if (variant.get_type() != Variant::CALLABLE) { + luaL_error(state, "attempt to call a %s value", get_type_name(variant).ascii().get_data()); + } Callable callable = variant; + VariantArguments var_args = args; Variant result = callable.callv(var_args.get_array()); - return to_lua(L, result); + return to_lua(state, result); } } diff --git a/src/utils/convert_godot_lua.cpp b/src/utils/convert_godot_lua.cpp index 9bb041f..4ec2af7 100644 --- a/src/utils/convert_godot_lua.cpp +++ b/src/utils/convert_godot_lua.cpp @@ -207,7 +207,7 @@ sol::stack_object variant_static_call_string_name(sol::this_state state, Variant Variant::call_static(type, method, variant_args.argv(), variant_args.argc(), result, error); if (error.error != GDEXTENSION_CALL_OK) { String message = String("Invalid static call to method '{0}' in type {1}").format(Array::make(method, Variant::get_type_name(type))); - lua_error(args.lua_state(), error, message); + lua_error(state, error, message); } return to_lua(state, result); } @@ -219,7 +219,7 @@ sol::stack_object variant_call_string_name(sol::this_state state, Variant& varia variant.call(method, variant_args.argv(), variant_args.argc(), result, error); if (error.error != GDEXTENSION_CALL_OK) { String message = String("Invalid call to method '{0}' in object of type {1}").format(Array::make(method, get_type_name(variant))); - lua_error(args.lua_state(), error, message); + lua_error(state, error, message); } return to_lua(state, result); }