-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Description
Hi! I'm trying to make a UI library for Lua called Glua (yes very original) that uses WinForms under the hood and I'm using the source generator (LuaObject) to implement a window. But regardless of what values I pass on the Lua side, I get this error:
Lua.LuaRuntimeException
HResult=0x80131500
Message=test.lua:1: bad argument #1 to 'create' (Number expected, got UserData)
Source=Lua
StackTrace:
at Lua.LuaRuntimeException.BadArgument(Traceback traceback, Int32 argumentId, String functionName, String expected, String actual)
at Lua.LuaFunctionExecutionContext.GetArgument[T](Int32 index)
at glua.gluaWindow.<>c.<.cctor>b__30_0(LuaFunctionExecutionContext context, Memory`1 buffer, CancellationToken ct) in C:\Users\dsml\source\repos\glua\glua\obj\Debug\net8.0-windows\Lua.SourceGenerator\Lua.SourceGenerator.LuaObjectGenerator\glua.gluaWindow.LuaObject.g.cs:line 19
at Lua.Runtime.LuaVirtualMachine.<ExecuteClosureAsync>d__0.MoveNext()
This is my Lua code:
-- test.lua
local w = window:create("test", 500, 500)
w:show()Here are the relevant C# snippets:
static async Task Main(string[] args)
{
args = [".\\test.lua"];
ApplicationConfiguration.Initialize();
LuaState state = LuaState.Create();
state.OpenStandardLibraries();
state.Environment["window"] = new gluaWindow();
var r = await state.DoFileAsync(args[0]);
foreach (LuaValue item in r)
{
Console.WriteLine(item.ToString());
}
}[LuaObject]
public partial class gluaWindow
{
static Form f;
#region constructor stuff
[LuaMember("create")]
public static void Create(string title, int width = 700, int height = 400)
{
f = new Form()
{
Text = title,
Width = width,
Height = height,
};
}
// ...If you need any other snippets, or know how to fix this, please tell me!
Metadata
Metadata
Assignees
Labels
No labels