|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
usernotfound Expert Cheater Reputation: 0
Joined: 21 Feb 2016 Posts: 115
|
Posted: Thu Mar 02, 2017 12:20 am Post subject: Simplifying AOB script |
|
|
I'm not very good with tables or loops yet, is there a way I could shorten this to have one function that cycles through the list of AOBs and prints out each scan result
Code: | aobList = {
a00 = "XX XX XX XX",
a01 = "XX XX XX XX",
a02 = "XX XX XX XX"
}
if openProcess("game.exe") then
function autoUpdate()
local a = AOBScan(aobList.a00)
for i=0, a.Count-2, 1 do
addr00 = (string.format("%X",getAddress(a[i])))
end
a.destroy()
local a = AOBScan(aobList.a01)
for i=0, a.Count-2, 1 do
addr01 = (string.format("%X",getAddress(a[i])))
end
a.destroy()
local a = AOBScan(aobList.a02)
for i=0, a.Count-2, 1 do
addr02 = (string.format("%X",getAddress(a[i])))
end
a.destroy()
print(addr00)
print(addr01)
print(addr02)
if a == nil then
return
end
end
end
createNativeThread(autoUpdate) |
|
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Thu Mar 02, 2017 1:37 am Post subject: |
|
|
This should work.
Code: |
local format = string.format
local aobLst = {
a00 = 'XX XX XX XX',
a01 = 'XX XX XX XX',
a02 = 'XX XX XX XX',
}
if openProcess('game.exe') then
function autoUpdate()
if aobLst then
for k, v in pairs(aobLst)
local rLst = AOBScan(v)
if rLst then
for i = 1, rLst.Count - 1 do
if rLst[i] then
print(format('%s: %08X', k, getAddress(rLst[i])))
end
end
end
end
end
end
createNativeThread(autoUpdate)
end
|
_________________
|
|
Back to top |
|
|
usernotfound Expert Cheater Reputation: 0
Joined: 21 Feb 2016 Posts: 115
|
Posted: Thu Mar 02, 2017 2:05 am Post subject: |
|
|
Thank you very much, that's a lot more elegant than what I had. one more thing if you don't mind, if I wanted to assign each first result from a scan to a global variable how would I do it with a loop like that? Like for instance if I changed the prints in my OP example to:
Code: | var1 = addr00
var2 = addr01
var3 = addr02 |
|
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Thu Mar 02, 2017 2:57 am Post subject: |
|
|
I would use a global table. (not lua's global table just a table)
so:
Code: |
AOBsLst = { }
local format = string.format
local aobLst = {
a00 = 'XX XX XX XX',
a01 = 'XX XX XX XX',
a02 = 'XX XX XX XX',
}
if openProcess('game.exe') then
function autoUpdate()
if aobLst then
for k, v in pairs(aobLst)
local rLst = AOBScan(v)
if rLst then
for i = 1, rLst.Count - 1 do
if rLst[i] then
print(format('%s: %08X', k, getAddress(rLst[i])))
AOBsLst[k] = v
end
end
end
end
end
end
createNativeThread(autoUpdate)
if AOBsLst then
print(AOBsLst.a00)
for k, v in pairs(AOBsLst)
print(format('%s: %08X', k, getAddress(v)))
end
end
end
|
EDIT:
Missed the first part.
Code: |
AOBsLst = { }
local format = string.format
local aobLst = {
a00 = 'XX XX XX XX',
a01 = 'XX XX XX XX',
a02 = 'XX XX XX XX',
}
if openProcess('game.exe') then
function autoUpdate()
if aobLst then
for k, v in pairs(aobLst)
local rLst = AOBScan(v)
if rLst then
for i = 1, rLst.Count - 1 do
if rLst[i] then
print(format('%s: %08X', k, getAddress(rLst[i])))
if i == 1 then
AOBsLst[k] = v
end
end
end
end
end
end
end
createNativeThread(autoUpdate)
if AOBsLst then
print(AOBsLst.a00)
for k, v in pairs(AOBsLst)
print(format('%s: %08X', k, getAddress(v)))
end
end
end
|
_________________
|
|
Back to top |
|
|
usernotfound Expert Cheater Reputation: 0
Joined: 21 Feb 2016 Posts: 115
|
Posted: Thu Mar 02, 2017 9:50 am Post subject: |
|
|
Much thanks again friend, cheers for now
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|