-- Author: mgr.inz.Player -- Source: https://www.cheatengine.org/forum/viewtopic.php?t=611168 -- Usage: -- - Copy this LUA file into CE's autorun folder -- - Put a line with the number you need right under your scan. For example, '2'nd: -- [ENABLE] -- aobscan(myPtr,48 8b 05 * * * * 48 85 c0 0f 85) -- LuaCall(find_Nth_Result_AOB('myPtr',2,[=[myPtr]=],"48 8b 05 * * * * 48 85 c0 0f 85")) function find_Nth_Result_AOB(symbol,N,start,pattern) if start==' 00000000' then return end if N<=1 then registerSymbol(symbol,start) return end local script='aobscanregion('..symbol..','..start..'+1,7fffffffffffffff,'..pattern..')\r\nregistersymbol('..symbol..')' local success=autoAssemble(script) if success and (N>2) then find_Nth_Result_AOB(symbol,N-1,string.format('%08X',getAddress(symbol)),pattern) end if not success then unregisterSymbol(symbol); error() end end local moduleInfos = {} local function getModuleStartAndSize(moduleName) local moduleAddress,moduleSize if moduleInfos[moduleName]==nil then moduleAddress = getAddressSafe(moduleName) if moduleAddress==nil then return 0,0 end moduleSize = getModuleSize(moduleName) moduleSize = ((moduleSize // 4096) + 1) * 4096 moduleInfos[moduleName] = {} moduleInfos[moduleName].moduleAddress=moduleAddress moduleInfos[moduleName].moduleSize=moduleSize return moduleAddress,moduleSize end return moduleInfos[moduleName].moduleAddress,moduleInfos[moduleName].moduleSize end function find_Nth_Result_AOBScanModule(symbol,moduleName,N,start,pattern) local moduleAddress,moduleSize=getModuleStartAndSize(moduleName) if start==' 00000000' then return end if N<=1 then registerSymbol(symbol,start) return end local script='aobscanregion('..symbol..','..start..'+1,moduleAddress+moduleSize,'..pattern..')\r\nregistersymbol('..symbol..')' local success=autoAssemble(script) if success and (N>2) then find_Nth_Result_AOB(symbol,N-1,string.format('%08X',getAddress(symbol)),pattern) end if not success then unregisterSymbol(symbol); error() end end