-- 实时控制台捕获 + 复制工具 (Rayfield GUI) local Rayfield = loadstring(game:HttpGet('https://raw.githubusercontent.com/shlexware/Rayfield/main/source'))() local LogService = game:GetService("LogService") -- 创建窗口 local Window = Rayfield:CreateWindow({ Name = "实时控制台捕获器", LoadingTitle = "加载实时日志...", LoadingSubtitle = "by Grok 3", ConfigurationSaving = { Enabled = false }, KeySystem = false }) local Tab = Window:CreateTab("实时日志", 4483362458) -- 日志存储 local fullLog = "" local maxLines = 500 -- 防止内存爆炸 -- 创建段落用于显示日志 local LogDisplay = Tab:CreateParagraph({ Title = "实时控制台日志 (滚动更新)", Content = "正在监听控制台输出...\n" }) -- 追加日志函数(带颜色标签) local function appendLog(message, msgType) local prefix = "" if msgType == Enum.MessageType.MessageOutput then prefix = "📄" elseif msgType == Enum.MessageType.MessageInfo then prefix = "ℹ️" elseif msgType == Enum.MessageType.MessageWarning then prefix = "⚠️" elseif msgType == Enum.MessageType.MessageError then prefix = "❌" else prefix = "🔹" end local line = string.format("[%s] %s %s\n", prefix, message:gsub("^%s+", ""), os.date("%H:%M:%S")) fullLog = fullLog .. line -- 限制行数 local lines = {} for l in fullLog:gmatch("[^\r\n]+") do table.insert(lines, l) end if #lines > maxLines then table.remove(lines, 1) end fullLog = table.concat(lines, "\n") -- 更新 GUI LogDisplay:Set({ Title = string.format("实时控制台日志 (%d 行)", #lines), Content = fullLog }) -- 自动滚动到底部(Rayfield 暂不支持原生滚动,但内容会更新) end -- 监听实时日志输出 LogService.MessageOut:Connect(function(message, msgType) appendLog(message, msgType) end) -- 复制按钮 Tab:CreateButton({ Name = "📋 复制全部日志", Callback = function() if fullLog ~= "" then setclipboard(fullLog) Rayfield:Notify({ Title = "✅ 已复制!", Content = "实时日志已复制到剪贴板 (" .. #fullLog:match("[^\n]+") .. " 行)", Duration = 4 }) else Rayfield:Notify({Title = "⚠️ 无内容", Content = "日志为空", Duration = 3}) end end, }) -- 清空按钮(可选) Tab:CreateButton({ Name = "🗑️ 清空日志", Callback = function() fullLog = "" LogDisplay:Set({Title = "实时控制台日志 (已清空)", Content = "日志已清空,等待新输出...\n"}) Rayfield:Notify({Title = "已清空", Content = "日志显示已重置", Duration = 3}) end, }) -- 初始提示 Rayfield:Notify({ Title = "实时捕获已启动", Content = "所有 print、warn、error 都会实时显示!", Duration = 5, Image = 4483362458 }) -- 可选:加载历史日志(启动时) spawn(function() wait(1) for _, msg in ipairs(LogService:GetLogHistory()) do appendLog(msg.message, msg.messageType) end end)