gpt4 book ai didi

c# - 如何将 WinForm 传递给 Lua (LuaInterface)?

转载 作者:太空宇宙 更新时间:2023-11-03 16:40:06 25 4
gpt4 key购买 nike

我想传递一个 WinForm 对象给 Lua,我的代码:

//Form1.cs

class Form1
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;

private void button1_Click(object sender, EventArgs e)
{
Lua m_lua = new Lua();
m_lua.DoFile("plugin.lua");
object[] objs = m_lua.GetFunction("OnLoad").Call(this, this.textBox1);
m_lua.Close();
}
}

--plugin.lua

function OnLoad(form, textbox)
textbox.Text = form.button1.Text -->Nil
textbox.Text = form.button1 -->Expect an object, but got a string!
end

最佳答案

尝试:

m_lua["textBox1"] = this.textBox1;
m_lua.DoString("textBox1.Text = 'hello world'");

关于c# - 如何将 WinForm 传递给 Lua (LuaInterface)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7926383/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com