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 


Catch Value Change Event in MemoryRecord

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
AntumDeluge
Cheater
Reputation: 0

Joined: 20 Dec 2018
Posts: 48

PostPosted: Thu Feb 21, 2019 2:27 pm    Post subject: Catch Value Change Event in MemoryRecord Reply with quote

So I know there is MemoryRecord.OnActivate & MemoryRecord.OnDeactivate to catch events when the record is activated & deactivated. But is there a property to catch events for when MemoryRecord.Value changes?[/code]

Edit: Something that could be used like:
Code:
local rec = getAddressList().getMemoryRecord(x)
rec.OnChange = function(sender)
    print('New value: ' .. rec.Value)
end

Edit: I would prefer to not have to use a Timer.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25796
Location: The netherlands

PostPosted: Thu Feb 21, 2019 2:47 pm    Post subject: Reply with quote

You can use OnGetDisplayValue and use a variable to keep track of the addresses

e.g:

Code:

local oldvalue=nil
AddressList[0].OnGetDisplayValue=function(sender,displayedvalue)
  local changed=oldvalue and (oldvalue~=displayedvalue)
  oldvalue=displayedvalue

  if changed then
    print('New value: ' .. displayedvalue)
  end
  return false,displayedvalue --false because you don't want to change the displayed value
end


(It's still using a timer though, for faster, use a debug register breakpoint)

_________________
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
View user's profile Send private message MSN Messenger
AntumDeluge
Cheater
Reputation: 0

Joined: 20 Dec 2018
Posts: 48

PostPosted: Thu Feb 21, 2019 4:45 pm    Post subject: Reply with quote

Okay, I will try that.

Is MemoryRecord.OnGetDisplayValue documented? Or is that just a custom method that you came up with?

Edit: Okay, I see. Looks like it uses a built-in timer so I don't have to create one myself.
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