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 


How to add an item whose value is [address1] minus [address2

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
skynet888
!BEWARE! Deletes post on answer
Reputation: 1

Joined: 12 Apr 2021
Posts: 66

PostPosted: Wed Jun 14, 2023 6:55 pm    Post subject: How to add an item whose value is [address1] minus [address2 Reply with quote

How to add an item whose value is [address1] minus [address2]?
Back to top
View user's profile Send private message  
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

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

PostPosted: Thu Jun 15, 2023 3:49 am    Post subject: This post has 1 review(s) Reply with quote

I'm going to give advice based on what I've interpreted of your request. If it's incorrect, please specify further.

Lua:
Code:

...
//-- Assuming that the value is a 4-byte whole integer value:
local difference = readInteger(address1) - readInteger(address2)
...


If you mean in ASM:
Code:

...
push rbx
mov rbx,[address1]
sub rbx,[address2]
mov [item],rbx
pop rbx
...
Back to top
View user's profile Send private message  
skynet888
!BEWARE! Deletes post on answer
Reputation: 1

Joined: 12 Apr 2021
Posts: 66

PostPosted: Thu Jun 15, 2023 9:35 pm    Post subject: Reply with quote

LeFiXER wrote:
I'm going to give advice based on what I've interpreted of your request. If it's incorrect, please specify further.

Lua:
Code:

...
//-- Assuming that the value is a 4-byte whole integer value:
local difference = readInteger(address1) - readInteger(address2)
...


If you mean in ASM:
Code:

...
push rbx
mov rbx,[address1]
sub rbx,[address2]
mov [item],rbx
pop rbx
...

Thank you so much for your help.
I want to know if I can add it to the cheat table, as shown in the picture.
We know that "X" is 547, "Y" is 712, and the difference between the two is 165. Can I add an item whose value is calculated by "Y - X" and updated with the values of X and Y?



1111111111.png
 Description:
 Filesize:  2.62 KB
 Viewed:  2382 Time(s)

1111111111.png


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

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

PostPosted: Fri Jun 16, 2023 5:19 am    Post subject: Reply with quote

How I would do that is using this simple Lua script
Code:

[ENABLE]
{$LUA}
if syntaxcheck then return end
if tmr then tmr.destroy(); tmr = nil end
local tmr = createTimer()
tmr.Interval = 500
tmr.OnTimer = function()
                if AddressList.getMemoryRecordByDescription('X') == nil or
                   AddressList.getMemoryRecordByDescription('Y') == nil then
                   tmr.destroy()
                   return
                end
                AddressList['Y - X'].value = tonumber(AddressList['Y'].value) - tonumber(AddressList['X'].value)
              end
{$ASM}
[DISABLE]
{$LUA}
if syntaxcheck then return end
tmr.destroy(); tmr = nil
Back to top
View user's profile Send private message  
skynet888
!BEWARE! Deletes post on answer
Reputation: 1

Joined: 12 Apr 2021
Posts: 66

PostPosted: Fri Jun 16, 2023 4:03 pm    Post subject: Reply with quote

LeFiXER wrote:
How I would do that is using this simple Lua script
Code:

[ENABLE]
{$LUA}
if syntaxcheck then return end
if tmr then tmr.destroy(); tmr = nil end
local tmr = createTimer()
tmr.Interval = 500
tmr.OnTimer = function()
                if AddressList.getMemoryRecordByDescription('X') == nil or
                   AddressList.getMemoryRecordByDescription('Y') == nil then
                   tmr.destroy()
                   return
                end
                AddressList['Y - X'].value = tonumber(AddressList['Y'].value) - tonumber(AddressList['X'].value)
              end
{$ASM}
[DISABLE]
{$LUA}
if syntaxcheck then return end
tmr.destroy(); tmr = nil

Thanks again. I found the cause of the error. I changed tmr to a global variable and I was able to disable it - "disable" doesn't seem to recognize the local variables defined in "enable"



333333333333.png
 Description:
 Filesize:  34.73 KB
 Viewed:  2330 Time(s)

333333333333.png



22222222222.png
 Description:
 Filesize:  12.15 KB
 Viewed:  2330 Time(s)

22222222222.png


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

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

PostPosted: Sat Jun 17, 2023 4:41 am    Post subject: Reply with quote

That's true, each section is independent of one another.
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 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