View previous topic :: View next topic |
Author |
Message |
vng21092 Grandmaster Cheater
Reputation: 15
Joined: 05 Apr 2013 Posts: 644
|
Posted: Thu Oct 08, 2015 7:10 pm Post subject: Just LUA Questions |
|
|
Hey guys, just a quick question. Does LUA have an equivalent of aobScanModule? If so, whats the syntax? Thanks.
Last edited by vng21092 on Sat Oct 17, 2015 7:50 pm; edited 1 time in total |
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Thu Oct 08, 2015 8:07 pm Post subject: |
|
|
Code: | local memscan = createMemScan()
local foundlist = createFoundList(memscan)
local bytes = "48 83 EC 28 E8 9B 03 00 00"
local module = "Calculator.exe"
local start = getAddress(module)
local stop = start + getModuleSize(module)
memscan.firstScan(
soExactValue, vtByteArray, rtRounded,
bytes, nil, start, stop, "+X-C-W",
fsmNotAligned, "1", true, false, false, false)
memscan.waitTillDone()
foundlist.initialize()
local address = foundlist.Address
for i = 0, foundlist.Count-1 do
print(address[i])
end
foundlist.Destroy()
memscan.Destroy() |
|
|
Back to top |
|
 |
vng21092 Grandmaster Cheater
Reputation: 15
Joined: 05 Apr 2013 Posts: 644
|
Posted: Thu Oct 08, 2015 8:30 pm Post subject: |
|
|
...wow that's a lot to take in, thanks. Just out of curiosity I was just reading up one of DBs older posts about aobscan where an array was returned. Near the end of the code he wrote Code: | aob.destroy()
aob = nil | What exactly does the destroy function do? And why set the variable to nil afterwards? Is there a downside to not doing this?
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Thu Oct 08, 2015 11:20 pm Post subject: |
|
|
Destroy cleans up the object on the Delphi side. Given that everything Cheat Engine exposes to Lua is just wrapped objects from Delphi, they need to be cleaned up in certain cases.
Setting to nil is more or less just cleanup code to ensure the object is not attempted to be used again. More or less garbage collection in a sense. It isn't needed once destroy is used, the object is already cleaned up at that point on the Delphi side.
_________________
- Retired. |
|
Back to top |
|
 |
panraven Grandmaster Cheater
Reputation: 62
Joined: 01 Oct 2008 Posts: 958
|
Posted: Fri Oct 09, 2015 3:47 am Post subject: |
|
|
The 'nil' is necessary in some case I guess. It may cause 'access violation' in some case if not.
Code: | local withNil = true
function localSL()
local sl = createStringlist()
sl.Destroy()
if withNil then
sl = nil
end
return sl
end
print("--- with nil")
local lsl = localSL()
print(lsl and lsl.Count or -1)
print("--- without nil")
withNil=false
lsl = localSL()
print(lsl and lsl.Count or -1) |
_________________
- Retarded. |
|
Back to top |
|
 |
vng21092 Grandmaster Cheater
Reputation: 15
Joined: 05 Apr 2013 Posts: 644
|
Posted: Fri Oct 09, 2015 7:39 am Post subject: |
|
|
ahh gotcha, thanks guys. Another question (sorry, trying to learn LUA), it seems that every time I edit a asm script with a luaCall in it, whenever I press "OK" the LUA part gets executed, is there anyway to stop that from happening? If I hit assign to cheat table the script doesn't get executed but when I edit it, it does.
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25804 Location: The netherlands
|
Posted: Fri Oct 09, 2015 7:53 am Post subject: |
|
|
Hmm, that's weird as luacall should also execute on assign to cheat table
Anyhow, I recommend you use this kind of code instead:
Code: |
{$lua}
if syntaxcheck==false then
--your lua code here
end
{$asm}
|
that way the lua code only gets executed when it's actually executed
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
vng21092 Grandmaster Cheater
Reputation: 15
Joined: 05 Apr 2013 Posts: 644
|
Posted: Fri Oct 09, 2015 9:12 am Post subject: |
|
|
hmm thanks DB that worked, but then I tried implementing this WITHIN the lua script itself but I guess it doesn't work that way?
Code: | function newFunction()
if (syntaxcheck == false) then
...my code...
end
end |
and then in the asm window I just wanna see
Code: | luaCall(myFunction()) |
|
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Fri Oct 09, 2015 11:12 am Post subject: |
|
|
That code is only preventing the function's code from running during script creation/update.
The rest of your Lua is still running. Maybe try something like:
Code: | {$lua}
if syntaxcheck then return end
{$asm}
[ENABLE]
blahblah
[DISABLE]
blahblah |
|
|
Back to top |
|
 |
vng21092 Grandmaster Cheater
Reputation: 15
Joined: 05 Apr 2013 Posts: 644
|
Posted: Sat Oct 10, 2015 8:41 pm Post subject: |
|
|
does ASM have any methods that can read the data off a LUA variable?
Code: | [Enable]
{$lua}
thisnumber = 1
{$asm}
cmp thisnumber,1
[Disable] | something like that?
|
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Oct 10, 2015 9:01 pm Post subject: |
|
|
Code: | [ENABLE]
{$lua}
autoAssemble([[
alloc(myvar,4)
registersymbol(myvar)
]])
writeInteger("myvar", 1)
{$asm}
cmp [myvar],1
[DISABLE]
unregistersymbol(myvar)
dealloc(myvar) |
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25804 Location: The netherlands
|
Posted: Sun Oct 11, 2015 1:14 am Post subject: |
|
|
registersymbol, and i think $globalluavar, but that one is ambiguous to use (difficult to predict if it's going to get handled as an hex, int or string)
also, the return value of lua sections will be interpreted as an autoassembler command (or multiple if you return a string with muktiple lines)
you can do something like:
Code: |
{$lua}
a1=0x123456
a2=a1+0x10
return string.format([[
define(a1,%x)
define(a2,%x)
]], a1, a2)
{$asm}
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
|