Lua练习笔录

相爱相杀

private string script = 

            
 function luaStr( str1 , str2 )
    return  str1 ..  str2
end

function luaNum( num1 , num2 )
    return num1 + num2
end


        ";
        LuaState lua = new LuaState();
        lua.Start();
        lua.DoString(script);

        LuaFunction lfuncStr = lua.GetFunction("luaStr");
        LuaFunction lfuncNum = lua.GetFunction("luaNum");

        if( lfuncStr != null)
        {
            object[] obj = lfuncStr.Call(11, 22);

            Debug.Log( "lua  str ->" + obj[0]);
        }

        if( lfuncNum != null)
        {
            object[] obj = lfuncNum.Call(11, 22);
            Debug.Log("lua  num ->" + obj[0]);
        }

原文地址:https://www.cnblogs.com/didiaodexi/p/7116527.html