吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 399|回复: 4
上一主题 下一主题
收起左侧

[Other] Cheat Engine自动保存CT插件lua版本

  [复制链接]
跳转到指定楼层
楼主
LazyTG 发表于 2026-9-18 14:13 回帖奖励
这是Cheat Engine 自动保存lua改进版,无需DLL
插件放在Cheat Engine\autorun文件夹里面,启动时候自动加载插件在菜单栏。
会保存配置文件在Cheat Engine本体目录下面AutoSaveCT.ini
[Lua] 纯文本查看 复制代码
local CONFIG_FILE=getCheatEngineDir()..'\\AutoSaveCT.ini'
local interval,path,prefix=60,getCheatEngineDir(),'自动保存'
local timer,settingsForm=nil,nil
local closeSaveEnabled=true
local mainForm=getMainForm()
local closeHandlerInstalled=false

local function trim(s)return(tostring(s or ''):gsub('^%s+',''):gsub('%s+$',''))end
local function loadConfig()
 local f=io.open(CONFIG_FILE,'r');if not f then return end
 for l in f:lines() do
  local k,v=l:match('^%s*([%w_]+)%s*=%s*(.-)%s*$')
  if k=='Interval'then interval=tonumber(v)or interval elseif k=='Path'and v~=''then path=v elseif k=='FileNamePrefix'and v~=''then prefix=v elseif k=='CloseSaveEnabled'then closeSaveEnabled=(v=='1'or v:lower()=='true')end
 end;f:close()
end
local function saveConfig()
 local f,e=io.open(CONFIG_FILE,'w');if not f then showMessage('配置保存失败:\n'..tostring(e));return end
 f:write('[Settings]\nInterval=',interval,'\nPath=',path,'\nFileNamePrefix=',prefix,'\nCloseSaveEnabled=',closeSaveEnabled and '1'or'0','\n');f:close()
end
local function saveCT(name,notice)
 if trim(path)==''then if notice then showMessage('请先设置保存路径。')end;return false end
 local file=string.format('%s\\%s_%s.CT',path,name,os.date('%H_%M_%S'));local ok,e=pcall(function()saveTable(file)end)
 if notice then showMessage(ok and('已保存:\n'..file)or('保存失败:\n'..tostring(e)))end;return ok
end
local function stopTimer()if timer then timer.destroy();timer=nil end end
local function startTimer()stopTimer();timer=createTimer(nil);timer.Interval=interval*1000;timer.OnTimer=function()saveCT(prefix,false)end end
local function toggleAutoSave()
 if timer then stopTimer();showMessage('自动保存已关闭。');return end
 if trim(path)==''then showMessage('请先设置保存路径。');return end
 startTimer();showMessage(string.format('自动保存已开启。\n间隔:%d 秒\n路径:%s',interval,path))
end
local function openSettings()
 if not settingsForm then
  settingsForm=createForm(false);settingsForm.Caption,settingsForm.Width,settingsForm.Height='自动保存CT基础设置',430,230;settingsForm.Position,settingsForm.BorderStyle=poScreenCenter,bsSingle
  -- 用户点击窗口右上角 X 时,CE 会释放窗体;清空引用以便下次重新创建。
  settingsForm.OnClose=function()
   settingsForm=nil
   return caFree
  end
  local function lab(t,y)local c=createLabel(settingsForm);c.Caption,c.Left,c.Top,c.Width=t,12,y+4,400 end
  local function edt(y,v)local c=createEdit(settingsForm);c.Left,c.Top,c.Width,c.Text=12,y,390,v;return c end
  lab('保存间隔(秒):',10);local ie=edt(32,tostring(interval));lab('保存路径(默认为 CE 目录):',66);local pe=edt(88,path);lab('文件名前缀(格式:前缀_小时_分钟_秒.CT):',122);local fe=edt(144,prefix)
  local b=createButton(settingsForm);b.Caption,b.Left,b.Top,b.Width='保存设置',95,180,110;b.OnClick=function()
   local n=tonumber(trim(ie.Text));if not n or n<1 then showMessage('请输入有效的保存间隔(至少 1 秒)。');return end
   path=trim(pe.Text);if path==''then showMessage('请输入保存路径。');return end
   interval=math.floor(n);prefix=trim(fe.Text);if prefix==''then prefix='自动保存'end;saveConfig();if timer then startTimer()end;settingsForm.hide();showMessage('设置已保存。')
  end
  local c=createButton(settingsForm);c.Caption,c.Left,c.Top,c.Width='取消',225,180,110;c.OnClick=function()settingsForm.hide()end
 end;settingsForm.show()
end
local function installCloseHandler()
 if closeHandlerInstalled then return end
 mainForm.OnClose=function(sender)
  mainForm.OnClose=nil;closeHandlerInstalled=false;stopTimer()
  if closeSaveEnabled then saveCT('关闭前保存',false)end
  return caFree
 end
 closeHandlerInstalled=true
end
local function uninstallCloseHandler()
 if closeHandlerInstalled then mainForm.OnClose=nil;closeHandlerInstalled=false end
end
loadConfig();local menu=mainForm.Menu
local root=createMenuItem(menu);root.Caption='自动保存CT';menu.Items.add(root)
local a=createMenuItem(root);a.Caption='基础设置';a.OnClick=openSettings;root.add(a)
local b=createMenuItem(root);b.Caption='开启/关闭自动保存';b.OnClick=toggleAutoSave;root.add(b)
local c=createMenuItem(root);c.Caption='手动保存';c.OnClick=function()saveCT(prefix,true)end;root.add(c)
local d=createMenuItem(root);d.Caption='关闭前自动保存';d.AutoCheck=true;d.Checked=closeSaveEnabled;d.OnClick=function()
 closeSaveEnabled=d.Checked;saveConfig();if closeSaveEnabled then installCloseHandler()else uninstallCloseHandler()end
end;root.add(d)
if closeSaveEnabled then installCloseHandler()end

PixPin_2026-09-18_14-08-43.png (40.58 KB, 下载次数: 0)

位置和选项

位置和选项

PixPin_2026-09-18_14-09-55.png (24.4 KB, 下载次数: 0)

设置界面

设置界面

自动保存CT修复版.zip

2 KB, 下载次数: 30, 下载积分: 吾爱币 -1 CB

免费评分

参与人数 1热心值 +1 收起 理由
Issacclark1 + 1 谢谢@Thanks!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

沙发
saomu007 发表于 2026-9-18 17:34
我的ce咋没有你说的那个文件夹
3#
afti 发表于 2026-9-18 18:28
4#
AEhahaha 发表于 2026-9-18 19:50
5#
遛你玩528 发表于 2026-9-18 21:16
感谢楼主无私分享
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - 52pojie.cn ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2026-9-19 01:21

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表