Request for CT Automation Feature

Ask about cheats/tables for single player games here
DrummerIX
Expert Cheater
Expert Cheater
Posts: 2885
Joined: Wed Mar 22, 2017 6:15 pm
Reputation: 0

Re: Request for CT Automation Feature

Post by DrummerIX »

I currently don't have much more time for this request. I'm sorry. I do think it's a nice feature that I may eventually research more of, but right now I'm kind of busy with some other things. You can copy those things back into the one I posted from the original post. Just look for things that are not there.

User avatar
dreamcactus
Expert Cheater
Expert Cheater
Posts: 144
Joined: Sat Jul 06, 2019 12:21 pm
Reputation: 0

Re: Request for CT Automation Feature

Post by dreamcactus »

"just" look for stuff that aint there he says , lols, dude i have 0 clue how to handle code its like a jungle to me , i dont get jack lol, ill gladly wait till you got some spare time to finish this for sure , no rush but was a great start for sure thanks a ton , btw ive atleast managed to add autoload on fresh start feature , for that single profile , from some old lua code i had laying around, heres the lua code, just gotta make sure to change both the DefaultProccessName and PROCESS_NAME at the bottom to your own game exe >

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

----
--
---- 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
local autoAttachTimerInterval = 100
local autoAttachTimerTicks = 0
local autoAttachTimerTickMax = 5000

local function autoAttachTimer_tick(timer)
	if autoAttachTimerTickMax > 0 and autoAttachTimerTicks >= autoAttachTimerTickMax then
		timer.destroy()
	end
	if getProcessIDFromProcessName(PROCESS_NAME) ~= nil then
		timer.destroy()
		openProcess(PROCESS_NAME)
        getAddressList().getMemoryRecordByDescription("Load Table State").active=true
	end
	autoAttachTimerTicks = autoAttachTimerTicks + 1
end

autoAttachTimer = createTimer(MainForm)
autoAttachTimer.Interval = autoAttachTimerInterval
autoAttachTimer.OnTimer = autoAttachTimer_tick
maybe someone else might like to help out on polishing this further besides you , not too hopeful bout that tho lol , but you never know :roll:
Last edited by dreamcactus on Thu Jul 08, 2021 6:40 am, edited 1 time in total.

aSwedishMagyar
Table Makers
Table Makers
Posts: 670
Joined: Mon Jul 06, 2020 3:19 am
Reputation: 1190

Re: Request for CT Automation Feature

Post by aSwedishMagyar »

dreamcactus wrote:
Thu Jul 08, 2021 6:25 am
"just" look for stuff that aint there he says , lols
maybe someone else might like to help out on polishing this further besides you , not too hopeful bout that tho lol :roll:
Do you actively try to be an annoying little puke or does it just come naturally to you?

User avatar
dreamcactus
Expert Cheater
Expert Cheater
Posts: 144
Joined: Sat Jul 06, 2019 12:21 pm
Reputation: 0

Re: Request for CT Automation Feature

Post by dreamcactus »

meh ...pretty naturally lols

8-) :lol:

User avatar
dreamcactus
Expert Cheater
Expert Cheater
Posts: 144
Joined: Sat Jul 06, 2019 12:21 pm
Reputation: 0

Re: Request for CT Automation Feature

Post by dreamcactus »

oh btw for anyone that dont know this for autohooking of CTs to game exes , you gotta add them into CEs settings under the
option named automatically attach to process named:

User avatar
EpicBirdi
Fearless Donors
Fearless Donors
Posts: 64
Joined: Sat Jul 21, 2018 2:22 pm
Reputation: 58

Re: Request for CT Automation Feature

Post by EpicBirdi »

getAutoAttachList().add("AutoAttachMyGame.exe")

Quite the interesting read over the two threads.. best of luck.

Try not to be so abrasive towards people when they offer help, though, even if you don't understand it. All I got was that you really wanted to be spoonfed the solution, with nothing in return. Some people are really nice and will take on the project but I can't see the reasoning in passively attacking the people who offered help in the first place.

User avatar
dreamcactus
Expert Cheater
Expert Cheater
Posts: 144
Joined: Sat Jul 06, 2019 12:21 pm
Reputation: 0

Re: Request for CT Automation Feature

Post by dreamcactus »

been a few there ...sup , btw ive been brainstorming how to further improve this automation feature ....after finding this , id like to integrate it

[Link]

if possible , aka to have it additionally autoload all .CEAs in game dir, without having to add .CEAs names one by one in LUA


btw is there a solution to not having to set the game exe twice , once at the top and once at the bottom of the lua script we hacked together?

heres a CT that incorporates current features , appreciated if someone could have a look at current code and maybe even a clean up if possible , thanks




@EpicBirdi, your right and i try to not be too abrasive ...just kinda have to defend myself when some folks lash out there....sorry , not my idea of fun either :mellow:
Attachments
NGS2SPAWNMOD.CT
(334.99 KiB) Downloaded 47 times

User avatar
dreamcactus
Expert Cheater
Expert Cheater
Posts: 144
Joined: Sat Jul 06, 2019 12:21 pm
Reputation: 0

Re: Request for CT Automation Feature

Post by dreamcactus »

so heres an update ...think i managed to remove the dual .exe input requirement for the lua for starters...
Attachments
NGS2SPAWNMOD.CT
(334.94 KiB) Downloaded 46 times

User avatar
dreamcactus
Expert Cheater
Expert Cheater
Posts: 144
Joined: Sat Jul 06, 2019 12:21 pm
Reputation: 0

Re: Request for CT Automation Feature

Post by dreamcactus »

as said this feature would be much appreciated >

....after finding this , id like to integrate it

[Link]

if possible , aka to have it additionally autoload all .CEAs in game dir, without having to add .CEAs names one by one in LUA

User avatar
dreamcactus
Expert Cheater
Expert Cheater
Posts: 144
Joined: Sat Jul 06, 2019 12:21 pm
Reputation: 0

Re: Request for CT Automation Feature

Post by dreamcactus »

anybody? would be much appreciated as usual guys, wheres my expert level CE crew at.... :), gonna need all hands on deck for this LUA update i recon 8-) ...appreciated alot , mean it , comes from the heart...., aim as usual is to make the automation include even more automation features and autoload all .CEAs in game dir where CT resides support is up next , now....., been told the old method of a additional plugin isnt even required no more hmmmm..... :|, if true ...could be cool

User avatar
dreamcactus
Expert Cheater
Expert Cheater
Posts: 144
Joined: Sat Jul 06, 2019 12:21 pm
Reputation: 0

Re: Request for CT Automation Feature

Post by dreamcactus »

dont want to bump too hard here , but anyone yet ?

User avatar
dreamcactus
Expert Cheater
Expert Cheater
Posts: 144
Joined: Sat Jul 06, 2019 12:21 pm
Reputation: 0

Re: Request for CT Automation Feature

Post by dreamcactus »

nobody? please

User avatar
dreamcactus
Expert Cheater
Expert Cheater
Posts: 144
Joined: Sat Jul 06, 2019 12:21 pm
Reputation: 0

Re: Request for CT Automation Feature

Post by dreamcactus »

bump for justice

ShyTwig16
Expert Cheater
Expert Cheater
Posts: 335
Joined: Thu Apr 06, 2017 7:14 pm
Reputation: 19

Re: Request for CT Automation Feature

Post by ShyTwig16 »

dreamcactus wrote:
Tue Oct 26, 2021 5:56 pm
as said this feature would be much appreciated >

....after finding this , id like to integrate it

[Link]

if possible , aka to have it additionally autoload all .CEAs in game dir, without having to add .CEAs names one by one in LUA
For the "autoload all .CEAs in game dir" you'd have to load the module then change the setting for the folder you want it to look for (I2CETableCEA.CEAFilesDirectory), you can use absolute paths for the folder to point it to the game folder. But that can change for every user so you should stick with using the relative path so it looks in the CT's folder to start. But in the end you'd just need to set up a loop looking up file names and checking file extensions for the ".CEA" extension.
Here's the CE functions you'd likely want (from "celua.txt" file).

Code: Select all

getFileList(Path:string, searchMask:string OPTIONAL, SearchSubDirs: boolean OPTIONAL, DirAttrib: integer OPTIONAL): Returns an indexed table with filenames
getDirectoryList(Path:string, SearchSubDirs: boolean OPTIONAL): Returns an indexed table with directory names
extractFileName(filepath): returns the filename of the path
extractFileExt(filepath): returns the file extension of the path
extractFileNameWithoutExt(filepath): Returns the filename of the path, without the extension
extractFilePath(filepath): removes the filename from the path
But with the relative paths it needs a CT file location to start, so with CE if your making new tables you have to make a table file and start that file for the module to work right; if you open CE and make a new file, it won't work with the relative paths tell you close CE and open the CT file because it will be looking in the CE directory. Only the table files will work if there is no relative paths that are found.

Plus keep in mind this module was setup to work with memory records on the CT, and it needs memrec to know if it's enabling or disabling a script (plus using it's description and id). But you could always use a dummy object in it's place.

And I need to update the CEF posts, it's an old version so I have no idea if it's working with newer versions of CE. But with the current module version using CE 7.3, I'm having issues with dealloc and unregisterSymbol. But it's changed a lot and is using other modules at this point and I'm not sure if posting a bunch of modules one of which is getting errors, would help or just make it more confusing for you. It's like 4 or 5 files for this one I think, but let me know if you want me to post them.

User avatar
dreamcactus
Expert Cheater
Expert Cheater
Posts: 144
Joined: Sat Jul 06, 2019 12:21 pm
Reputation: 0

Re: Request for CT Automation Feature

Post by dreamcactus »

oh thank god! finally a proper reply ....give me some time to work through it all , but THANKS alot my bro ShyTwig16 ....very much appreciated as usual , you guys are the best ...comes from the heart

update>

ok ...finished reading it all, and suffice to say ...my brain hurts ALOT...once again lol :? , if possible you could use one of the CTs preferably the most recent one i posted and maybe just modify it to include said function , you know me ....i suck at comprehension of code or instructions , hell the last time you did so i had to pass em on to DrummerIX to get a working global function one can simply copy paste into other CTs and it just working ...without having to be a coder aka userfriendly, also ive been told most recent version of CE dont even need it as a separate .DLL no more ...and should fit into LUA script fully

Post Reply

Who is online

Users browsing this forum: AmazonBot, Aranaktu, kolonus, Lilleman, SemrushBot