/// <summary>
 /// 当LuaVM加载Lua文件的时候,这里就会被调用,
 /// 用户可以自定义加载行为,只要返回byte[]即可。
 /// </summary>
 public override byte[] ReadFile(string fileName)
 {
     string[] _depart = fileName.Split('-');
     if (_depart.Length > 1)
     {
         return(module.ReadFile(_depart[0], _depart[1]));
     }
     else
     {
         return(module.ReadFile(fileName));
     }
 }
Exemplo n.º 2
0
    static int ReadFile(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                GameContent.ToLuaModule obj = (GameContent.ToLuaModule)ToLua.CheckObject <GameContent.ToLuaModule>(L, 1);
                string arg0 = ToLua.CheckString(L, 2);
                byte[] o    = obj.ReadFile(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 3)
            {
                GameContent.ToLuaModule obj = (GameContent.ToLuaModule)ToLua.CheckObject <GameContent.ToLuaModule>(L, 1);
                string arg0 = ToLua.CheckString(L, 2);
                string arg1 = ToLua.CheckString(L, 3);
                byte[] o    = obj.ReadFile(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: GameContent.ToLuaModule.ReadFile"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }