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 

Timer Action On Address Collection

Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Extensions
View previous topic :: View next topic  
Author Message
Grandmaster Cheater
Reputation: 34

Joined: 01 Oct 2008
Posts: 792

PostPosted: Tue Sep 20, 2016 11:48 pm    Post subject: Timer Action On Address Collection Reply with quote

The attached ct contained a function, inspired by this post .


Try make a lua timer function,
1.the OnTimer function check a list of address,
1.1 if each addr is readable and somehow checked it is a valid address (eg. if it is a float value health address, check with float value between 0.01 and 99999 etc), something on individual address, (eg.check if its float value below 50 then add 100 float to the address),
1.3.otherwise remove this addr from the address list.

The function TimerActionOnAddressCollection is defined as

TimerActionOnAddressCollection( id, interval, action)
-- id : a non empty string, used to retrieve the action object associated to the id ;
-- interval: the internal timer Interval number, if omitted when defining the action function, it will be default to 100 ms;
-- action: the defined function to be act on each address in the collected address list,
    -- signature : function(addr,...)
       1st parameter is necessary address, it will be a number type inside the action function. See example in test script. If this action function explicitly return true, the addr address 1st parameter value will be removed from the address collection. Use this to remove invalid address.

alternative form:

TimerActionOnAddressCollection( id, true)
return the id associated action object if defined, return nil if not defined.

TimerActionOnAddressCollection( id, false)
destroy the internal timer and remove the association between the id and the action function.

Example in test scrtipt:

remove association for id 'Up' and 'Dn'

TimerActionOnAddressCollection('Up',false) -- remove old definition

Defined the action to be associated to 'Up' and 'Dn',
'Dn' action is decrease the address integer value by 1 per 100ms,
'Up' action is to add the address integer value 0x90 if it is below 0x90, so up the value to 0x90+0x90=0x120.

local Up = TimerActionOnAddressCollection('Up',function(addr,keep) -- define action
  if not keep and math.floor(addr/4) % 2 ~= 0 then return true end -- test to active remove invalid address
  local n = readInteger(addr)
  if n<0x90 then writeInteger(addr,n+0x90) end

local Dn = TimerActionOnAddressCollection('Dn',function(addr,keep)
  if not keep and math.floor(addr/4) % 2 ~= 0 then return true end
  local n = readInteger(addr)
  if n>0 then writeInteger(addr,n-1) end

Manipulate the action object:

Get the action object

  local Up = TimerActionOnAddressCollection('Up',true)
  local Dn = TimerActionOnAddressCollection('Dn',true)

The action object can be treat as a timer (but it is in 'table' type, not 'userdata'), so it can be Stop/Resume the timer like :

  if Up then Up.Enabled = not Up.Enabled end
  if Dn then Dn.Enabled = not Dn.Enabled end

It has to be check if it is 'nil' to prevent error.

To add an address into the address collection, use the object as a function and address to be added as 1st parameter:

if Up and Dn and Up:alive() and Dn:alive() and readInteger'__' then
  local b = GetAddress'__+10'
  for i=0,15 do

Other api for the action object, 'Up' as example instance of an action object:

  Up:alive() - check if the timer is still there, should not be use if return false.
  Up:Destroy() -- destroy timer and the action object
  Up.timer -- the timer
  Up.ID -- the associated id
  Up.interval -- the initial set timer interval, use Up.Interval = 500 to change the timer Interval (capital 'I'), or Up.timer.Interval = 500

  Up, action object instance, itself is a table, its key is address number collected.



 Filename:  timerActionOnAddress.CT
 Filesize:  8.09 KB
 Downloaded:  1050 Time(s)

- Retarded.
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 Extensions 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