Пример #1
0
        /// <summary>
        /// Loads file from given path.
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        private bool LoadFile(string filePath)
        {
            if (!File.Exists(filePath))
            {
                Log.Error("ScriptManager.LoadFile: File '{0}' not found.", filePath);
                return(false);
            }

            // Load file
            var result = Melua.luaL_loadfile(GL, filePath);

            if (result != 0)
            {
                Log.Error("ScriptManager.LoadFile: Failed to compile '{0}' (Error code: {1}).\n{2}", filePath, result, Melua.lua_tostring(GL, -1));
                return(false);
            }

            // Execute it
            if (Melua.lua_pcall(GL, 0, 0, 0) != 0)
            {
                Log.Error("ScriptManager.LoadFile: Failed to load '{0}'.\n{1}", filePath, Melua.lua_tostring(GL, -1));
                return(false);
            }

            return(true);
        }