-- 直接从GG的保存列表读取选中的项并生成脚本 local function generateScriptFromSelected() -- 获取当前列表 local List = gg.getListItems() -- 筛选选中的项 local selectedItems = {} for _, item in ipairs(List) do if item.selected then table.insert(selectedItems, item) end end -- 如果没有选中的项,提示并退出 if #selectedItems == 0 then print("没有选中的项") return end -- 生成脚本内容 local scriptContent = "gg.setValues{\n" for _, item in ipairs(selectedItems) do scriptContent = scriptContent .. string.format( " {address = %s, value = %s, flags = %s},\n", item.address, item.value, item.flags ) end scriptContent = scriptContent .. "}" -- 保存脚本到文件 local folder = "/storage/emulated/0/外挂制作/机智脚本/" local newNum = 1 local newFileName while true do newFileName = folder .. string.format("%06d", newNum) .. "_静态基址脚本.lua" local fileCheck = io.open(newFileName, "r") if not fileCheck then break end fileCheck:close() newNum = newNum + 1 end local fileHandle = io.open(newFileName, "w") if fileHandle then fileHandle:write(scriptContent) fileHandle:close() print('脚本已导出到:' .. newFileName) else print("无法写入文件,请检查文件夹权限或手动确认路径 " .. newFileName .. " 是否存在") end end -- 执行生成脚本的函数 generateScriptFromSelected()