public object[] LuaDoFile(string scriptName)
 {
     if (lua != null && Initialized)
     {
         return(lua.DoFile(NTGResourceController.LuaPath(scriptName)));
     }
     return(null);
 }
 static int LuaPath(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         string arg0 = ToLua.CheckString(L, 1);
         string o    = NTGResourceController.LuaPath(arg0);
         LuaDLL.lua_pushstring(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #3
0
        public virtual string FindFileError(string fileName)
        {
            if (Path.IsPathRooted(fileName))
            {
                return(fileName);
            }

            StringBuilder sb = StringBuilderCache.Acquire();

            if (fileName.EndsWith(".lua"))
            {
                fileName = fileName.Substring(0, fileName.Length - 4);
            }

            for (int i = 0; i < searchPaths.Count; i++)
            {
                sb.AppendFormat("\n\tno file '{0}'", searchPaths[i]);
            }

            sb = sb.Replace("?", fileName);

            sb.AppendFormat("\n\tno file '{0}'", NTGResourceController.LuaPath(fileName));

            if (beZip)
            {
                int    pos    = fileName.LastIndexOf('/');
                string bundle = "";

                if (pos > 0)
                {
                    bundle = fileName.Substring(0, pos);
                    bundle = bundle.Replace('/', '_');
                    bundle = string.Format("lua_{0}.unity3d", bundle);
                }
                else
                {
                    bundle = "lua.unity3d";
                }

                sb.AppendFormat("\n\tno file '{0}' in {1}", fileName, bundle);
            }

            return(StringBuilderCache.GetStringAndRelease(sb));
        }
Пример #4
0
        public string FindFile(string fileName)
        {
            if (fileName == string.Empty)
            {
                return(string.Empty);
            }

            if (Path.IsPathRooted(fileName))
            {
                if (!fileName.EndsWith(".lua"))
                {
                    fileName += ".lua";
                }

                return(fileName);
            }

            if (fileName.EndsWith(".lua"))
            {
                fileName = fileName.Substring(0, fileName.Length - 4);
            }

            string fullPath = null;

            for (int i = 0; i < searchPaths.Count; i++)
            {
                fullPath = searchPaths[i].Replace("?", fileName);

                if (File.Exists(fullPath))
                {
                    return(fullPath);
                }
            }

            fullPath = NTGResourceController.LuaPath(fileName);
            if (File.Exists(fullPath))
            {
                return(fullPath);
            }

            return(null);
        }