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 


Lua Script | Read Address from the Cheat Table

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

Joined: 29 Jul 2021
Posts: 2

PostPosted: Thu Jul 29, 2021 4:59 am    Post subject: Lua Script | Read Address from the Cheat Table Reply with quote

Here is my LUA script, u might recognize it XD.

Code:
address = 0x7FF940DB2014

lastValue=0;

function checkKeys(timer)
  if (isKeyPressed(VK_R)) then
    if lastValue ~= 1 then
      writeQword(address, 1)
      lastValue=1
    end
  else
    if lastValue ~= 0 then
      writeQword(address, 0)
      lastValue=0
    end
  end

end

t=createTimer(nil)
timer_setInterval(t, 100)
timer_onTimer(t, checkKeys)
timer_setEnabled(t, true)


The address at the top comes from a script in my table:
Please see attachment ce1.PNG

This is what I call it in the script:
Please see attachment ce2.PNG

The address changes every restart, I manually update my LUA.
How can I make it so the LUA script can find the correct address automatically?

I usually just google stuff like this, but I'm not well versed in LUA so I don't know what to search.

Help please.

P.S. Sorry I had to use attachments for the images. The forum won't let me post URLs yet.



ce1.PNG
 Description:
 Filesize:  3.39 KB
 Viewed:  2767 Time(s)

ce1.PNG



ce2.PNG
 Description:
 Filesize:  12.85 KB
 Viewed:  2767 Time(s)

ce2.PNG


Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Thu Jul 29, 2021 5:16 am    Post subject: Reply with quote

You either need to use an AOB injection script to pull the pointer from memory or find a basepointer manually.

This is an AOB injection script. I've commented the lines so you can understand what is happening.

Code:

[ENABLE]

aobscanmodule([injection_point_name],[process_name],[AOB]) // (Note: Don't include the square brackets)
// AOB will look something like this and should be unique to work 48 8D 64 24 D8 C6 05 * * * * 00 4C (Note: */? are wildcards meaning it doesn't matter what the byte is)
alloc(newmem,$1000,[injection_point_name])
// This allocates 1,000 bytes near the injection point to write new code


label(code)
label(return)

newmem:
// New code goes here (Note: instructions under "code:" will still execute)

code:
// Below will be a few lines of instructions that followed the injection point
  lea rsp,[rsp-28]
  jmp return
// After executing instructions, return back to the injection point so the game can continue executing normally

[injection_point_name]:
  jmp newmem
// jump to newly allocated memory, i.e. injection point

return:
registersymbol([injection_point_name])
// register a symbol so that CE can find where to remove the code when you disable it, or for use as reference within the table

[DISABLE]

[injection_point_name]:
  db 48 8D 64 24 D8
// restore original bytes at the point of injection

unregistersymbol([injection_point_name])
dealloc(newmem)
// Bit of housework.
Back to top
View user's profile Send private message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Thu Jul 29, 2021 5:35 am    Post subject: Reply with quote

This works for me.

Code:
address = 0x7FF940DB2014

lastValue=0;

function checkKeys(timer)
  if (isKeyPressed(VK_R)) then
    if lastValue == 0 then
  --sleep(100)
      writeQword(address, 1)
      lastValue=1
      --print(lastValue)
  else
      writeQword(address, 0)
      lastValue=0
      --print(lastValue)
    end
  end

end

if t then t.Destroy() t=nil end
t=createTimer(nil)
timer_setInterval(t, 100)
timer_onTimer(t, checkKeys)
timer_setEnabled(t, true)
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Thu Jul 29, 2021 5:45 am    Post subject: Reply with quote

Looks like your memory record uses the symbol "set_suck" so you can use that as the address just make it a string. The functions CE has with an address parameter takes strings or numbers.

Thus just change the first line to something like this.
Code:
address = "set_suck"

And I would nest it under the script that sets the symbol being used.

And just to note you can even use more complex addresses if need be.
Code:
address = "set_suck+4"

Code:
address = "[mySymbol]+4"

Code:
address = "[[game.exe+DEAD]+BEEF]+C"

_________________
Back to top
View user's profile Send private message Visit poster's website
cheatH13
How do I cheat?
Reputation: 0

Joined: 29 Jul 2021
Posts: 2

PostPosted: Thu Jul 29, 2021 6:09 pm    Post subject: This works. Thanks. Reply with quote

TheyCallMeTim13 wrote:
Looks like your memory record uses the symbol "set_suck" so you can use that as the address just make it a string. The functions CE has with an address parameter takes strings or numbers.

Thus just change the first line to something like this.
Code:
address = "set_suck"


This works, thanks!
Funny thing, this is actually the first thing I tried, but I didn't use quotation marks, so that's why it didn't work. SMH, could have saved myself a lot of time.
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