Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Auto Assemble Script Return a Variable

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Octopus3535
How do I cheat?
Reputation: 0

Joined: 12 Mar 2016
Posts: 4
Location: the void

PostPosted: Sat Feb 25, 2023 5:35 pm    Post subject: Auto Assemble Script Return a Variable Reply with quote

I have this auto assemble script that works fine in CE but I can't get it to work with the trainer. I don't know what I'm doing wrong, I tried looking through some examples and didn't see anything through or with context. Can someone be so kind and point out my errors?

Code:
local script = [[
[ENABLE]
aobscanmodule(tst,app.exe,C3 F4 0F 17 40 10 C3)
alloc(newmem,$1000,tst)
globalalloc(pntr,100)
label(code)
label(return)

newmem:

code:
  push rax
  mov rax,pntr
  mov [rax],rdx
  pop rax
  movss xmm0,[rax+18]
  jmp return

tst+01:
  jmp newmem
return:
registersymbol(tst)
[DISABLE]

tst+01:
  db F4 0F 17 40 10

unregistersymbol(tst)
dealloc(newmem)
]]

function LastResortChange(sender)
if (UDF1.LastResort.State==cbChecked)then
   autoAssemble(script, true)
   UDF1.LastResortVal.Text = "checked"
   else
   autoAssemble(script, false)
   UDF1.LastResortVal.Text = "unchecked"
   end
end

function ButtonRefreshClick(sender)
 setProperty(UDF1.LastResortText,"Text", readQword(pntr))
end
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Sat Feb 25, 2023 7:06 pm    Post subject: Reply with quote

celua.txt:
Quote:
autoAssemble(text, targetself OPTIONAL, disableInfo OPTIONAL) : runs the auto assembler with the given text. Returns true on success, with as secondary a table you can use when disabling (if targetself is set it will assemble into Cheat Engine itself). If disableInfo is provided the [Disable] section will be handled
autoAssemble(text, disableInfo OPTIONAL)

Relevant topic:
https://www.cheatengine.org/forum/viewtopic.php?p=5767333

In your case, use an upvalue.
Code:
...
local scriptDisableInfo
function LastResortChange(sender)
  ...
  local success
  success, scriptDisableInfo = autoAssemble(script)
  ...
  autoAssemble(script, scriptDisableInfo)
  scriptDisableInfo = nil
  ...

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites