0

C#.NET プログラムに lua スクリプトを実装しようとしていますが、コードを実行すると、メソッドの 1 つが実行されません。

クラスは次のとおりです。

namespace Program1
{
    public class LuaFunctions
    {
        Client Client { get; set; }
        private Lua lua { get; set; }

        public LuaFunctions(Client c) {
            this.Client = c;
            this.lua = new Lua();

            registerFunctions();
        }

        public void ExecuteCode(string code)
        {
            this.lua.DoString(code);
        }

        private void registerFunctions()
        {
            lua.RegisterFunction("message", this, this.GetType().GetMethod("Message"));
            lua.RegisterFunction("pname", this, this.GetType().GetMethod("playername"));
        }

        public void Message(string s)
        {
            System.Windows.Forms.MessageBox.Show(s);
        }

        public string playername()
        {
            return Client.Player.Name;
        }
   }
}

lua コードのこの行「message(pname)」を実行すると、メソッド「playername()」を実行して値を返そうとさえしないため、「pname」が「returning」であるため、DoString() 行でクラッシュします。ヌル。

4

2 に答える 2