-
Couldn't load subscription status.
- Fork 42
Open
Description
Short description
I'm trying to make an async function (Task) what is return a LuaTable with the [LuaMember] attribute. I'm trying to return a LuaValue inside a Task (bc sometimes I want to return a nil), but the code generator trying to make a new LuaValue from a LuaValue, what is not possible.
If I make it sync and remove the Task and async keys it's smart enough to understand that it's already a LuaValue, but it's not when I want to do this. But I want it to be async.
Versions
- .NET: 9.0
- LuaCSharp: 0.4.2 (latest nuget)
A little example
[LuaMember]
public async Task<LuaValue> Test(bool val)
{
// do something
if (val)
return new LuaTable();
else
return LuaValue.Nil;
}The generated code, where the result variable is LuaValue:
static readonly global::Lua.LuaFunction __function_Test = new global::Lua.LuaFunction("Test", async (context, buffer, ct) =>
{
var userData = context.GetArgument<global::LuaController.UHF.UHFControllerWrapper>(0);
var arg1 = context.GetArgument<bool>(1);
var result = await userData.Test(arg1); // result is a LuaValue
buffer.Span[0] = new global::Lua.LuaValue(result); // error here
return 1;
}
);Received compile time error message:
Severity Code Description Project File Line Suppression State Details
Error (active) CS1503 Argument 1: cannot convert from 'Lua.LuaValue' to 'bool' LuaController [...]\LuaController\obj\Debug\net9.0\Lua.SourceGenerator\Lua.SourceGenerator.LuaObjectGenerator\LuaController.UHF.UHFControllerWrapper.LuaObject.g.cs 207
Akeit0
Metadata
Metadata
Assignees
Labels
No labels