Request for CT Automation Feature
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Request for CT Automation Feature
got abit of an current issue i cant get solved , its about my CTs , i need a universal lua script i can copy and paste into my CTs so they will save Cheats ive enabled including set Values to a profile and reload said Profile with enabled Cheats and Set Values but also lock those Values so game cant change it ,on fresh start of CT, been at this for a while and cant find a solution , im no coder just a average joe gamer here , so please bare with me, thanks a bunch
this is what i gots so far in my original thread, but dont work >
viewtopic.php?p=194651#p194651
this is what i gots so far in my original thread, but dont work >
viewtopic.php?p=194651#p194651
-
- Expert Cheater
- Posts: 852
- Joined: Fri Oct 12, 2018 10:25 pm
- Reputation: 896
Re: Request for CT Automation Feature
I've been working on a table for a future game for quite some time, and I've been using the register to load and save values. So you could use that if needed.
Simple code to save/create a register entry and save a value and load back when needed:
You just gotta remember that everything you save is going to be a string, so you need to turn it into a number by using tonumber. You could pretty much automate it to run on opening the table.
With that you should already be able to save and load anything. The other way I can think of is to use I/O.
Simple code to save/create a register entry and save a value and load back when needed:
Code: Select all
function saveVariables()
settings=getSettings('SAVE') -- Create entry or get if it already exists
settings.Value['SavedVariable'] == readInteger('VariableToSave')
end
function loadVariables()
settings=getSettings('SAVE') -- Create entry or get if it already exists
writeInteger('VariableToSave',tonumber(settings.Value['SavedVariable'])) --Everything will always return as string
end
With that you should already be able to save and load anything. The other way I can think of is to use I/O.
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Re: Request for CT Automation Feature
finally! someone thats willing to help out here with actual solutions instead of having me start learning code lols, anyhow , so do i just copy paste above code into the lua window of my CT and save it and itll autosave my current settings to a profile including my set values and then when i start said CT from fresh aka restart it itll autoload previous settings from said CT including Set Values and freeze those values so the game dont tamper with them? if so , i love you! if not still do lol, but seriously then id need said function implemented , would appreciate a ton for sure , really would, thanks so far
Re: Request for CT Automation Feature
Thanks GreenHouse!
-
- Expert Cheater
- Posts: 852
- Joined: Fri Oct 12, 2018 10:25 pm
- Reputation: 896
Re: Request for CT Automation Feature
Well, you would need to complete the "Save" script with everything you want to save. And then the same for Load. As for freezing it depends on what you mean exactly. But if it's LUA settings, then you could add a timer that keeps setting them or that checks each value, not sure how good that would be performance wise though.dreamcactus wrote: ↑Sun Jul 04, 2021 2:42 pmfinally! someone thats willing to help out here with actual solutions instead of having me start learning code lols, anyhow , so do i just copy paste above code into the lua window of my CT and save it and itll autosave my current settings to a profile including my set values and then when i start said CT from fresh aka restart it itll autoload previous settings from said CT including Set Values and freeze those values so the game dont tamper with them? if so , i love you! if not still do lol, but seriously then id need said function implemented , would appreciate a ton for sure , really would, thanks so far
What I said is pretty simplistic, just for saving and loading. For a more extensive thing, it would require some more work and testing.
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Re: Request for CT Automation Feature
well ideally youd able to make this script work, thats unless yours already does this and more? , cause its already gots profile saving feature also saves cheats settings, or it should just currently dont, maybe have a looksee at it , it used to need you having to set a custom prefix to whatever cheat you enable with "Auto Set:" to every cheat , if you could manage to get it to work , it would save a ton of work having to manually type in said prefix into every single cheat into cheat description
viewtopic.php?p=192578#p192578
viewtopic.php?p=193573#p193573
viewtopic.php?p=194651#p194651
and thus am currently stuck at this , since i dont know code and need someone to figure this out for me , since i cant figure out how to remove the prefix aka "AUTO SET:"
requirement
viewtopic.php?p=192578#p192578
viewtopic.php?p=193573#p193573
viewtopic.php?p=194651#p194651
Code: Select all
local format = string.format
local strE = string.empty or STRING_EMPTY or ''
local t = translate
if AddressList == nil then
AddressList = getAddressList()
end
if MainForm == nil then
MainForm = getMainForm()
end
if getCEVersion == nil or getCEVersion() < 6.5 then
messageDialog('It is recommended to use at least Cheat Engine 6.7! (Your Version: '..getCEVersion()..')', mtError, mbOK)
end
errorOnLookupFailure(false)
setGlobalDelayBetweenHotkeyActivation(200)
DefaultProccessName = "pcsx2.exe"
strings_add(getAutoAttachList(), DefaultProccessName)
PRIVATETABLE, SWITCHSUPPORT = true, false
function cycleFullCompact(sender,force)
local state = not(compactmenuitem.Caption == 'Compact View Mode')
if force~=nil then state = not force end
compactmenuitem.Caption = state and 'Compact View Mode' or 'Full View Mode'
getMainForm().Splitter1.Visible = state
getMainForm().Panel4.Visible = state
getMainForm().Panel5.Visible = state
end
function addCompactMenu()
if compactmenualreadyexists then return end
local parent = getMainForm().Menu.Items
compactmenuitem = createMenuItem(parent); parent.add(compactmenuitem)
compactmenuitem.Caption = 'Compact View Mode'
compactmenuitem.OnClick = cycleFullCompact
compactmenualreadyexists = 'yes'
end
addCompactMenu()
cycleFullCompact(nil, true)
----
--
---- Logger
local Logger = {
LEVELS = {
OFF = 0,
FATAL = 1,
ERROR = 2,
WARN = 3,
INFO = 4,
DEBUG = 5,
TRACE = 6
},
Level = 0,
}
for k, v in pairs(Logger.LEVELS) do
Logger[k:lower()] = function( ... ) return end
Logger[k:lower() .. 'f'] = function( ... ) return end
-- Logger[k:lower()] = function(msg, ex) return print(msg, ex) end
-- Logger[k:lower() .. 'f'] = function(msg, ... ) return print(string.format(msg, ... )) end
end
--
---- Helpers
local function split(s, delimiter)
result = {}
for match in (s .. delimiter):gmatch('(.-)' .. delimiter) do
table.insert(result, match)
end
return result
end
local function interp(s, tbl)
if s == nil then return end
return (s:gsub('($%b{})', function(w) return tbl[w:sub(3, -2)] or w end))
end
--
---- I2CETState
I2CETState = {
--
---- Settings
DefaultState = 'default',
SaveFileName = 'I2CETState.${StateName}.txt',
UseMemoryRecordDescriptions = false,
LineEnd = '\n',
DisableBeforeLoad = true,
PrintStatus = false, --true,
SaveValueMatch = 'AUTO SET:',
LineDelimiter = '',
ScriptID = 'I2CETStateSCRIPTID',
BlackList = {
['_[ I2CETState ]_'] = true,
['_[ Save Table State ]_'] = true,
['_[ Load Table State ]_'] = true,
},
}
function I2CETState.saveTableState(stateName)
if not inMainThread() then
synchronize(function(thread)
I2CETState.saveTableState(stateName)
end)
return
end
Logger.trace()
if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then
getLuaEngine().show()
end
if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then
print(format('Saving Table State: %s', stateName))
end
local le = I2CETState.LineEnd
local ld = I2CETState.LineDelimiter
local sid = I2CETState.ScriptID
local svm = I2CETState.SaveValueMatch
if stateName == nil then
stateName = I2CETState.DefaultState
end
local fileName = interp(I2CETState.SaveFileName, { StateName = stateName } )
Logger.debugf('Using state file name: "%s"', fileName)
local fileStr = strE
for i = 0, AddressList.Count - 1 do
local mr = AddressList.getMemoryRecord(i)
if I2CETState.BlackList[mr.Description] ~= true
and mr.Description:sub(0, 16) ~= 'Load Table State'
and mr.Description:sub(0, 16) ~= 'Save Table State' then
local id = tostring(mr.ID)
if I2CETState.UseMemoryRecordDescriptions then
id = mr.Description
end
if mr.Type == vtAutoAssembler and mr.Active then
Logger.debugf('Saving script state: %d, %d, "%s"', mr.Index, mr.ID, mr.Description)
fileStr = fileStr..id..ld..sid..ld..tostring(mr.Active)..le
elseif mr.Description:sub(0, #svm) == svm and mr.Value ~= '??' then
Logger.debugf('Saving value: %d, %d, "%s", %s', mr.Index, mr.ID, mr.Description, mr.Value)
fileStr = fileStr..id..ld..mr.Value..ld..tostring(mr.Active)..le
end
end
end
local f, err = io.open(fileName, 'w')
if err then
Logger.errorf('The file could not be opened, "%s", %s', fileName, err)
elseif f and not err then
f:write(fileStr)
f:close()
end
end
saveTableState = I2CETState.saveTableState
function I2CETState.loadTableState(stateName)
if not inMainThread() then
synchronize(function(thread)
I2CETState.loadTableState(stateName)
end)
return
end
Logger.trace()
if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then
getLuaEngine().show()
end
if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then
print(format('Setting Table State: %s', stateName))
end
local le = I2CETState.LineEnd
local ld = I2CETState.LineDelimiter
local sid = I2CETState.ScriptID
local svm = I2CETState.SaveValueMatch
if stateName == nil then
stateName = I2CETState.DefaultState
end
local fileName = interp(I2CETState.SaveFileName, { StateName = stateName } )
Logger.debugf('Using state file name: "%s"', fileName)
local fileStr = nil
local f, err = io.open(fileName, 'r')
if err then
Logger.infof('The local file could not be opened, "%s", %s', fileName, err)
local tableFile = findTableFile(fileName)
if tableFile == nil then
Logger.warnf('file not found, "%s"', fileName)
return
end
local stream = tableFile.getData()
local bytes = stream.read(stream.Size)
for i = 1, #bytes do
if fileStr == nil then
fileStr = strE
end
fileStr = fileStr .. string.char(bytes[i])
end
elseif f and not err then
fileStr = f:read('*all')
f:close()
else
Logger.errorf('The file could not be opened, "%s"', fileName)
end
if I2CETState.DisableBeforeLoad then
for i = AddressList.Count - 1, 0, -1 do
local mr = AddressList.getMemoryRecord(i)
if I2CETState.BlackList[mr.Description] ~= true
and mr.Description:sub(0, 16) ~= 'Load Table State'
and mr.Description:sub(0, 16) ~= 'Save Table State' then
if mr.Active then
Logger.infof('Disabling memory record: %d, %d, "%s"', mr.Index, mr.ID, mr.Description)
if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then
print(format('Disabling: %s', mr.Description))
end
mr.Active = false
while mr.Async and mr.AsyncProcessing do
checkSynchronize()
end
sleep(0)
end
end
end
sleep(0)
end
if fileStr == nil then
Logger.info('File string was nil')
return
end
local lines = split(fileStr, I2CETState.LineEnd)
for i, v in ipairs(lines) do
if v ~= nil and v ~= strE then
local data = split(v, I2CETState.LineDelimiter)
local mr = nil
if I2CETState.UseMemoryRecordDescriptions then
mr = AddressList.getMemoryRecordByDescription(data[1])
else
mr = AddressList.getMemoryRecordByID(tonumber(data[1]))
end
if mr ~= nil then
if mr.Type == vtAutoAssembler and mr.Active == false
and data[2] == sid and data[3] == tostring(true) then
Logger.infof('Enabling memory record: %d, %d, "%s"', mr.Index, mr.ID, mr.Description)
if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then
print(format('Enabling: "%s"', mr.Description))
end
mr.Active = true
while mr.Async and mr.AsyncProcessing do
checkSynchronize()
end
sleep(0)
elseif mr.Type ~= vtAutoAssembler and mr.Description:sub(0, #svm) == svm then
if mr.Value == '??' then
Logger.warnf('Memory record value not set: %d, %d, "%s", "%s"', mr.Index, mr.ID, mr.Description, mr.Value)
if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then
print(format('Memory record value not set: "%s", "%s"', mr.Description, mr.Value))
end
else
Logger.infof('Setting memory record: %d, %d, "%s", %s, %s', mr.Index, mr.ID, mr.Description, data[1], data[2])
if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then
print(format('Setting: "%s", %s', mr.Description, data[2]))
end
mr.Value = data[2]
if data[3] == tostring(true) then
mr.Active = true
end
end
end
else
Logger.errorf('Memory record not found: "%s", "%s", "%s"', data[1], data[2], v)
end
end
end
if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then
print(format('Table State Set: %s', stateName))
getLuaEngine().hide()
end
end
loadTableState = I2CETState.loadTableState
----
PROCESS_NAME = 'pcsx2.exe'
--------
-------- Auto Attach
--------
local autoAttachTimer = nil ---- variable to hold timer object
local autoAttachTimerInterval = 100 ---- Timer intervals are in milliseconds
local autoAttachTimerTicks = 0 ---- variable to count number of times the timer has run
local autoAttachTimerTickMax = 5000 ---- Set to zero to disable ticks max
local function autoAttachTimer_tick(timer) ---- Timer tick call back
---- Destroy timer if max ticks is reached
if autoAttachTimerTickMax > 0 and autoAttachTimerTicks >= autoAttachTimerTickMax then
timer.destroy()
end
---- Check if process is running
if getProcessIDFromProcessName(PROCESS_NAME) ~= nil then
timer.destroy() ---- Destroy timer
openProcess(PROCESS_NAME) ---- Open the process
--
--
---- Just a way to do this with the NameList,
---- thus you can just add to the list to make it work with other memory records.
end
autoAttachTimerTicks = autoAttachTimerTicks + 1 ---- Increase ticks
end
autoAttachTimer = createTimer(getMainForm()) ---- Create timer with the main form as it's parent
autoAttachTimer.Interval = autoAttachTimerInterval ---- Set timer interval
autoAttachTimer.OnTimer = autoAttachTimer_tick ---- Set timer tick call back
requirement
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Re: Request for CT Automation Feature
hope this explains it better
-
- Expert Cheater
- Posts: 852
- Joined: Fri Oct 12, 2018 10:25 pm
- Reputation: 896
Re: Request for CT Automation Feature
I did previously see that, but that's just too much code for me to bother making sense of it. What is the exact problem with it? That the strings are saved like: "AUTOSET: 100", and you want to remove "AUTOSET:" and leave the number or whatever it has?
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Re: Request for CT Automation Feature
naww i want to have the lua code NOT require the prefix "AUTOSET:" to have to be in whatever Cheats Description at the start in order for the save function to actually work for example like this>
AUTOSET: Infinite health
but just have the cheat description not require changing at all, like so
infinite health
AUTOSET: Infinite health
but just have the cheat description not require changing at all, like so
infinite health
Re: Request for CT Automation Feature
I'm not at computer but this might be what is required to save everything regardless of auto set text. I may have missed deleting an end for one of the if and since I'm on my phone, I cannot be suredreamcactus wrote: ↑Sun Jul 04, 2021 4:23 pm
viewtopic.php?p=192578#p192578
viewtopic.php?p=193573#p193573
viewtopic.php?p=194651#p194651
and thus am currently stuck at this , since i dont know code and need someone to figure this out for me , since i cant figure out how to remove the prefix aka "AUTO SET:"Code: Select all
local format = string.format local strE = string.empty or STRING_EMPTY or '' local t = translate if AddressList == nil then AddressList = getAddressList() end if MainForm == nil then MainForm = getMainForm() end if getCEVersion == nil or getCEVersion() < 6.5 then messageDialog('It is recommended to use at least Cheat Engine 6.7! (Your Version: '..getCEVersion()..')', mtError, mbOK) end errorOnLookupFailure(false) setGlobalDelayBetweenHotkeyActivation(200) DefaultProccessName = "pcsx2.exe" strings_add(getAutoAttachList(), DefaultProccessName) PRIVATETABLE, SWITCHSUPPORT = true, false function cycleFullCompact(sender,force) local state = not(compactmenuitem.Caption == 'Compact View Mode') if force~=nil then state = not force end compactmenuitem.Caption = state and 'Compact View Mode' or 'Full View Mode' getMainForm().Splitter1.Visible = state getMainForm().Panel4.Visible = state getMainForm().Panel5.Visible = state end function addCompactMenu() if compactmenualreadyexists then return end local parent = getMainForm().Menu.Items compactmenuitem = createMenuItem(parent); parent.add(compactmenuitem) compactmenuitem.Caption = 'Compact View Mode' compactmenuitem.OnClick = cycleFullCompact compactmenualreadyexists = 'yes' end addCompactMenu() cycleFullCompact(nil, true) ---- -- ---- Logger local Logger = { LEVELS = { OFF = 0, FATAL = 1, ERROR = 2, WARN = 3, INFO = 4, DEBUG = 5, TRACE = 6 }, Level = 0, } for k, v in pairs(Logger.LEVELS) do Logger[k:lower()] = function( ... ) return end Logger[k:lower() .. 'f'] = function( ... ) return end -- Logger[k:lower()] = function(msg, ex) return print(msg, ex) end -- Logger[k:lower() .. 'f'] = function(msg, ... ) return print(string.format(msg, ... )) end end -- ---- Helpers local function split(s, delimiter) result = {} for match in (s .. delimiter):gmatch('(.-)' .. delimiter) do table.insert(result, match) end return result end local function interp(s, tbl) if s == nil then return end return (s:gsub('($%b{})', function(w) return tbl[w:sub(3, -2)] or w end)) end -- ---- I2CETState I2CETState = { -- ---- Settings DefaultState = 'default', SaveFileName = 'I2CETState.${StateName}.txt', UseMemoryRecordDescriptions = false, LineEnd = '\n', DisableBeforeLoad = true, PrintStatus = false, --true, SaveValueMatch = 'AUTO SET:', LineDelimiter = '', ScriptID = 'I2CETStateSCRIPTID', BlackList = { ['_[ I2CETState ]_'] = true, ['_[ Save Table State ]_'] = true, ['_[ Load Table State ]_'] = true, }, } function I2CETState.saveTableState(stateName) if not inMainThread() then synchronize(function(thread) I2CETState.saveTableState(stateName) end) return end Logger.trace() if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then getLuaEngine().show() end if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then print(format('Saving Table State: %s', stateName)) end local le = I2CETState.LineEnd local ld = I2CETState.LineDelimiter local sid = I2CETState.ScriptID local svm = I2CETState.SaveValueMatch if stateName == nil then stateName = I2CETState.DefaultState end local fileName = interp(I2CETState.SaveFileName, { StateName = stateName } ) Logger.debugf('Using state file name: "%s"', fileName) local fileStr = strE for i = 0, AddressList.Count - 1 do local mr = AddressList.getMemoryRecord(i) if I2CETState.BlackList[mr.Description] ~= true and mr.Description:sub(0, 16) ~= 'Load Table State' and mr.Description:sub(0, 16) ~= 'Save Table State' then local id = tostring(mr.ID) if I2CETState.UseMemoryRecordDescriptions then id = mr.Description end if mr.Type == vtAutoAssembler and mr.Active then Logger.debugf('Saving script state: %d, %d, "%s"', mr.Index, mr.ID, mr.Description) fileStr = fileStr..id..ld..sid..ld..tostring(mr.Active)..le elseif mr.Value ~= '??' then Logger.debugf('Saving value: %d, %d, "%s", %s', mr.Index, mr.ID, mr.Description, mr.Value) fileStr = fileStr..id..ld..mr.Value..ld..tostring(mr.Active)..le end end end local f, err = io.open(fileName, 'w') if err then Logger.errorf('The file could not be opened, "%s", %s', fileName, err) elseif f and not err then f:write(fileStr) f:close() end end saveTableState = I2CETState.saveTableState function I2CETState.loadTableState(stateName) if not inMainThread() then synchronize(function(thread) I2CETState.loadTableState(stateName) end) return end Logger.trace() if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then getLuaEngine().show() end if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then print(format('Setting Table State: %s', stateName)) end local le = I2CETState.LineEnd local ld = I2CETState.LineDelimiter local sid = I2CETState.ScriptID local svm = I2CETState.SaveValueMatch if stateName == nil then stateName = I2CETState.DefaultState end local fileName = interp(I2CETState.SaveFileName, { StateName = stateName } ) Logger.debugf('Using state file name: "%s"', fileName) local fileStr = nil local f, err = io.open(fileName, 'r') if err then Logger.infof('The local file could not be opened, "%s", %s', fileName, err) local tableFile = findTableFile(fileName) if tableFile == nil then Logger.warnf('file not found, "%s"', fileName) return end local stream = tableFile.getData() local bytes = stream.read(stream.Size) for i = 1, #bytes do if fileStr == nil then fileStr = strE end fileStr = fileStr .. string.char(bytes[i]) end elseif f and not err then fileStr = f:read('*all') f:close() else Logger.errorf('The file could not be opened, "%s"', fileName) end if I2CETState.DisableBeforeLoad then for i = AddressList.Count - 1, 0, -1 do local mr = AddressList.getMemoryRecord(i) if I2CETState.BlackList[mr.Description] ~= true and mr.Description:sub(0, 16) ~= 'Load Table State' and mr.Description:sub(0, 16) ~= 'Save Table State' then if mr.Active then Logger.infof('Disabling memory record: %d, %d, "%s"', mr.Index, mr.ID, mr.Description) if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then print(format('Disabling: %s', mr.Description)) end mr.Active = false while mr.Async and mr.AsyncProcessing do checkSynchronize() end sleep(0) end end end sleep(0) end if fileStr == nil then Logger.info('File string was nil') return end local lines = split(fileStr, I2CETState.LineEnd) for i, v in ipairs(lines) do if v ~= nil and v ~= strE then local data = split(v, I2CETState.LineDelimiter) local mr = nil if I2CETState.UseMemoryRecordDescriptions then mr = AddressList.getMemoryRecordByDescription(data[1]) else mr = AddressList.getMemoryRecordByID(tonumber(data[1])) end if mr ~= nil then if mr.Type == vtAutoAssembler and mr.Active == false and data[2] == sid and data[3] == tostring(true) then Logger.infof('Enabling memory record: %d, %d, "%s"', mr.Index, mr.ID, mr.Description) if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then print(format('Enabling: "%s"', mr.Description)) end mr.Active = true while mr.Async and mr.AsyncProcessing do checkSynchronize() end sleep(0) else if mr.Value == '??' then Logger.warnf('Memory record value not set: %d, %d, "%s", "%s"', mr.Index, mr.ID, mr.Description, mr.Value) if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then print(format('Memory record value not set: "%s", "%s"', mr.Description, mr.Value)) end else Logger.infof('Setting memory record: %d, %d, "%s", %s, %s', mr.Index, mr.ID, mr.Description, data[1], data[2]) if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then print(format('Setting: "%s", %s', mr.Description, data[2])) end mr.Value = data[2] if data[3] == tostring(true) then mr.Active = true end end end else Logger.errorf('Memory record not found: "%s", "%s", "%s"', data[1], data[2], v) end end end if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then print(format('Table State Set: %s', stateName)) getLuaEngine().hide() end end loadTableState = I2CETState.loadTableState ---- PROCESS_NAME = 'pcsx2.exe' -------- -------- Auto Attach -------- local autoAttachTimer = nil ---- variable to hold timer object local autoAttachTimerInterval = 100 ---- Timer intervals are in milliseconds local autoAttachTimerTicks = 0 ---- variable to count number of times the timer has run local autoAttachTimerTickMax = 5000 ---- Set to zero to disable ticks max local function autoAttachTimer_tick(timer) ---- Timer tick call back ---- Destroy timer if max ticks is reached if autoAttachTimerTickMax > 0 and autoAttachTimerTicks >= autoAttachTimerTickMax then timer.destroy() end ---- Check if process is running if getProcessIDFromProcessName(PROCESS_NAME) ~= nil then timer.destroy() ---- Destroy timer openProcess(PROCESS_NAME) ---- Open the process -- -- ---- Just a way to do this with the NameList, ---- thus you can just add to the list to make it work with other memory records. end autoAttachTimerTicks = autoAttachTimerTicks + 1 ---- Increase ticks end autoAttachTimer = createTimer(getMainForm()) ---- Create timer with the main form as it's parent autoAttachTimer.Interval = autoAttachTimerInterval ---- Set timer interval autoAttachTimer.OnTimer = autoAttachTimer_tick ---- Set timer tick call back
requirement
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Re: Request for CT Automation Feature
thanks man shall test that out asap, finally we getting this in motion...
Re: Request for CT Automation Feature
I'm trying again. I think this change might work. I changed the code in the quote abovedreamcactus wrote: ↑Sun Jul 04, 2021 4:23 pmwell ideally youd able to make this script work, thats unless yours already does this and more? , cause its already gots profile saving feature also saves cheats settings, or it should just currently dont, maybe have a looksee at it , it used to need you having to set a custom prefix to whatever cheat you enable with "Auto Set:" to every cheat , if you could manage to get it to work , it would save a ton of work having to manually type in said prefix into every single cheat into cheat description
viewtopic.php?p=192578#p192578
viewtopic.php?p=193573#p193573
viewtopic.php?p=194651#p194651
and thus am currently stuck at this , since i dont know code and need someone to figure this out for me , since i cant figure out how to remove the prefix aka "AUTO SET:"Code: Select all
local format = string.format local strE = string.empty or STRING_EMPTY or '' local t = translate if AddressList == nil then AddressList = getAddressList() end if MainForm == nil then MainForm = getMainForm() end if getCEVersion == nil or getCEVersion() < 6.5 then messageDialog('It is recommended to use at least Cheat Engine 6.7! (Your Version: '..getCEVersion()..')', mtError, mbOK) end errorOnLookupFailure(false) setGlobalDelayBetweenHotkeyActivation(200) DefaultProccessName = "pcsx2.exe" strings_add(getAutoAttachList(), DefaultProccessName) PRIVATETABLE, SWITCHSUPPORT = true, false function cycleFullCompact(sender,force) local state = not(compactmenuitem.Caption == 'Compact View Mode') if force~=nil then state = not force end compactmenuitem.Caption = state and 'Compact View Mode' or 'Full View Mode' getMainForm().Splitter1.Visible = state getMainForm().Panel4.Visible = state getMainForm().Panel5.Visible = state end function addCompactMenu() if compactmenualreadyexists then return end local parent = getMainForm().Menu.Items compactmenuitem = createMenuItem(parent); parent.add(compactmenuitem) compactmenuitem.Caption = 'Compact View Mode' compactmenuitem.OnClick = cycleFullCompact compactmenualreadyexists = 'yes' end addCompactMenu() cycleFullCompact(nil, true) ---- -- ---- Logger local Logger = { LEVELS = { OFF = 0, FATAL = 1, ERROR = 2, WARN = 3, INFO = 4, DEBUG = 5, TRACE = 6 }, Level = 0, } for k, v in pairs(Logger.LEVELS) do Logger[k:lower()] = function( ... ) return end Logger[k:lower() .. 'f'] = function( ... ) return end -- Logger[k:lower()] = function(msg, ex) return print(msg, ex) end -- Logger[k:lower() .. 'f'] = function(msg, ... ) return print(string.format(msg, ... )) end end -- ---- Helpers local function split(s, delimiter) result = {} for match in (s .. delimiter):gmatch('(.-)' .. delimiter) do table.insert(result, match) end return result end local function interp(s, tbl) if s == nil then return end return (s:gsub('($%b{})', function(w) return tbl[w:sub(3, -2)] or w end)) end -- ---- I2CETState I2CETState = { -- ---- Settings DefaultState = 'default', SaveFileName = 'I2CETState.${StateName}.txt', UseMemoryRecordDescriptions = false, LineEnd = '\n', DisableBeforeLoad = true, PrintStatus = false, --true, SaveValueMatch = 'AUTO SET:', LineDelimiter = '', ScriptID = 'I2CETStateSCRIPTID', BlackList = { ['_[ I2CETState ]_'] = true, ['_[ Save Table State ]_'] = true, ['_[ Load Table State ]_'] = true, }, } function I2CETState.saveTableState(stateName) if not inMainThread() then synchronize(function(thread) I2CETState.saveTableState(stateName) end) return end Logger.trace() if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then getLuaEngine().show() end if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then print(format('Saving Table State: %s', stateName)) end local le = I2CETState.LineEnd local ld = I2CETState.LineDelimiter local sid = I2CETState.ScriptID local svm = I2CETState.SaveValueMatch if stateName == nil then stateName = I2CETState.DefaultState end local fileName = interp(I2CETState.SaveFileName, { StateName = stateName } ) Logger.debugf('Using state file name: "%s"', fileName) local fileStr = strE for i = 0, AddressList.Count - 1 do local mr = AddressList.getMemoryRecord(i) if I2CETState.BlackList[mr.Description] ~= true and mr.Description:sub(0, 16) ~= 'Load Table State' and mr.Description:sub(0, 16) ~= 'Save Table State' then local id = tostring(mr.ID) if I2CETState.UseMemoryRecordDescriptions then id = mr.Description end if mr.Type == vtAutoAssembler and mr.Active then Logger.debugf('Saving script state: %d, %d, "%s"', mr.Index, mr.ID, mr.Description) fileStr = fileStr..id..ld..sid..ld..tostring(mr.Active)..le elseif mr.Value ~= '??' then Logger.debugf('Saving value: %d, %d, "%s", %s', mr.Index, mr.ID, mr.Description, mr.Value) fileStr = fileStr..id..ld..mr.Value..ld..tostring(mr.Active)..le end end end local f, err = io.open(fileName, 'w') if err then Logger.errorf('The file could not be opened, "%s", %s', fileName, err) elseif f and not err then f:write(fileStr) f:close() end end saveTableState = I2CETState.saveTableState function I2CETState.loadTableState(stateName) if not inMainThread() then synchronize(function(thread) I2CETState.loadTableState(stateName) end) return end Logger.trace() if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then getLuaEngine().show() end if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then print(format('Setting Table State: %s', stateName)) end local le = I2CETState.LineEnd local ld = I2CETState.LineDelimiter local sid = I2CETState.ScriptID local svm = I2CETState.SaveValueMatch if stateName == nil then stateName = I2CETState.DefaultState end local fileName = interp(I2CETState.SaveFileName, { StateName = stateName } ) Logger.debugf('Using state file name: "%s"', fileName) local fileStr = nil local f, err = io.open(fileName, 'r') if err then Logger.infof('The local file could not be opened, "%s", %s', fileName, err) local tableFile = findTableFile(fileName) if tableFile == nil then Logger.warnf('file not found, "%s"', fileName) return end local stream = tableFile.getData() local bytes = stream.read(stream.Size) for i = 1, #bytes do if fileStr == nil then fileStr = strE end fileStr = fileStr .. string.char(bytes[i]) end elseif f and not err then fileStr = f:read('*all') f:close() else Logger.errorf('The file could not be opened, "%s"', fileName) end if I2CETState.DisableBeforeLoad then for i = AddressList.Count - 1, 0, -1 do local mr = AddressList.getMemoryRecord(i) if I2CETState.BlackList[mr.Description] ~= true and mr.Description:sub(0, 16) ~= 'Load Table State' and mr.Description:sub(0, 16) ~= 'Save Table State' then if mr.Active then Logger.infof('Disabling memory record: %d, %d, "%s"', mr.Index, mr.ID, mr.Description) if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then print(format('Disabling: %s', mr.Description)) end mr.Active = false while mr.Async and mr.AsyncProcessing do checkSynchronize() end sleep(0) end end end sleep(0) end if fileStr == nil then Logger.info('File string was nil') return end local lines = split(fileStr, I2CETState.LineEnd) for i, v in ipairs(lines) do if v ~= nil and v ~= strE then local data = split(v, I2CETState.LineDelimiter) local mr = nil if I2CETState.UseMemoryRecordDescriptions then mr = AddressList.getMemoryRecordByDescription(data[1]) else mr = AddressList.getMemoryRecordByID(tonumber(data[1])) end if mr ~= nil then if mr.Type == vtAutoAssembler and mr.Active == false and data[2] == sid and data[3] == tostring(true) then Logger.infof('Enabling memory record: %d, %d, "%s"', mr.Index, mr.ID, mr.Description) if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then print(format('Enabling: "%s"', mr.Description)) end mr.Active = true while mr.Async and mr.AsyncProcessing do checkSynchronize() end sleep(0) elseif mr.Type ~= vtAutoAssembler then if mr.Value == '??' then Logger.warnf('Memory record value not set: %d, %d, "%s", "%s"', mr.Index, mr.ID, mr.Description, mr.Value) if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then print(format('Memory record value not set: "%s", "%s"', mr.Description, mr.Value)) end else Logger.infof('Setting memory record: %d, %d, "%s", %s, %s', mr.Index, mr.ID, mr.Description, data[1], data[2]) if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then print(format('Setting: "%s", %s', mr.Description, data[2])) end mr.Value = data[2] if data[3] == tostring(true) then mr.Active = true end end end else Logger.errorf('Memory record not found: "%s", "%s", "%s"', data[1], data[2], v) end end end if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.WARN then print(format('Table State Set: %s', stateName)) getLuaEngine().hide() end end loadTableState = I2CETState.loadTableState ---- PROCESS_NAME = 'pcsx2.exe' -------- -------- Auto Attach -------- local autoAttachTimer = nil ---- variable to hold timer object local autoAttachTimerInterval = 100 ---- Timer intervals are in milliseconds local autoAttachTimerTicks = 0 ---- variable to count number of times the timer has run local autoAttachTimerTickMax = 5000 ---- Set to zero to disable ticks max local function autoAttachTimer_tick(timer) ---- Timer tick call back ---- Destroy timer if max ticks is reached if autoAttachTimerTickMax > 0 and autoAttachTimerTicks >= autoAttachTimerTickMax then timer.destroy() end ---- Check if process is running if getProcessIDFromProcessName(PROCESS_NAME) ~= nil then timer.destroy() ---- Destroy timer openProcess(PROCESS_NAME) ---- Open the process -- -- ---- Just a way to do this with the NameList, ---- thus you can just add to the list to make it work with other memory records. end autoAttachTimerTicks = autoAttachTimerTicks + 1 ---- Increase ticks end autoAttachTimer = createTimer(getMainForm()) ---- Create timer with the main form as it's parent autoAttachTimer.Interval = autoAttachTimerInterval ---- Set timer interval autoAttachTimer.OnTimer = autoAttachTimer_tick ---- Set timer tick call back
requirement
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Re: Request for CT Automation Feature
nope , didnt work ...
update> ok lemme check , again lol
update> ok lemme check , again lol
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Re: Request for CT Automation Feature
nope , wont save current enabled states and values , the I2CETState.casual.txt is empty and on startup cheats arent enabled
Re: Request for CT Automation Feature
I won't be able to debug it until Tuesday. If no one has helped you, I will try again then.
Who is online
Users browsing this forum: bluesky0120, KittyLunav2, Neobleak, shanejpurcell, Skibosh