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 


Pre-fill Scan Range

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials
View previous topic :: View next topic  
Author Message
juntalis
Newbie cheater
Reputation: 2

Joined: 13 Mar 2013
Posts: 12

PostPosted: Thu Oct 23, 2014 8:19 pm    Post subject: Pre-fill Scan Range Reply with quote

Some programs always allocate memory as the same fixed address. (pcsx2, for instance, does so at 20000000) When dealing with those programs a lot, it becomes convenient to pre-fill the scan range with the fixed range.

Code:

set_scanrange = (function(frmMain)
   -- Enclosed in an anonymous function call in order to
   -- cache the result of getMainForm while avoiding the
   -- need to pollute the script's locals.
   local function find(name)
      return frmMain.findComponentByName(name)
   end

   local function dec2hex(nValue, maybe_size)
      local size = maybe_size or 0
      local fmt = '%'
      if type(nValue) == 'string' then nValue = tonumber(nValue) end
      if size ~= 0 then fmt = fmt .. '0' .. tostring(size) end
      fmt = fmt .. 'X'
      return string.format(fmt, nValue)
   end

   -- Pretty sure we can cache the results of the 'find'
   -- calls, but whatever.
   return function(fromaddr, toaddr)
      local fromctrl = find('FromAddress')
      local toctrl = find('ToAddress')
      if type(fromaddr) ~= 'string' then
         fromaddr = dec2hex(fromaddr)
      end
      if type(toaddr) ~= 'string' then
         toaddr = dec2hex(toaddr)
      end
      fromctrl.Lines.Text = fromaddr
      toctrl.Lines.Text = toaddr
   end
end)(getMainForm())

set_scanrange('20000000', '2A000000')


Note: This only works once Cheat Engine has attached to a process, so you'll most likely need to add the call to the handler for onOpenProcess.
Back to top
View user's profile Send private message
xxhehe
Expert Cheater
Reputation: 0

Joined: 11 Mar 2015
Posts: 136

PostPosted: Sat Oct 06, 2018 9:41 pm    Post subject: Re: Pre-fill Scan Range Reply with quote

juntalis wrote:
Some programs always allocate memory as the same fixed address. (pcsx2, for instance, does so at 20000000) When dealing with those programs a lot, it becomes convenient to pre-fill the scan range with the fixed range.

Code:

set_scanrange = (function(frmMain)
   -- Enclosed in an anonymous function call in order to
   -- cache the result of getMainForm while avoiding the
   -- need to pollute the script's locals.
   local function find(name)
      return frmMain.findComponentByName(name)
   end

   local function dec2hex(nValue, maybe_size)
      local size = maybe_size or 0
      local fmt = '%'
      if type(nValue) == 'string' then nValue = tonumber(nValue) end
      if size ~= 0 then fmt = fmt .. '0' .. tostring(size) end
      fmt = fmt .. 'X'
      return string.format(fmt, nValue)
   end

   -- Pretty sure we can cache the results of the 'find'
   -- calls, but whatever.
   return function(fromaddr, toaddr)
      local fromctrl = find('FromAddress')
      local toctrl = find('ToAddress')
      if type(fromaddr) ~= 'string' then
         fromaddr = dec2hex(fromaddr)
      end
      if type(toaddr) ~= 'string' then
         toaddr = dec2hex(toaddr)
      end
      fromctrl.Lines.Text = fromaddr
      toctrl.Lines.Text = toaddr
   end
end)(getMainForm())

set_scanrange('20000000', '2A000000')


Note: This only works once Cheat Engine has attached to a process, so you'll most likely need to add the call to the handler for onOpenProcess.


ce6.8.1
error:[string "
..."]:30: attempt to index a nil value (field 'Lines')
js error
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Sun Oct 07, 2018 2:02 am    Post subject: Reply with quote

FromAddress and ToAddress are Edit objects, not Memo Objects, so they do not have Line properties

Also, this script can be rewritten to:
Code:

function set_scanrange(from,to)
  MainForm.FromAddress.Text=from
  MainForm.ToAddress.Text=to
end

_________________
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
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials 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 cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites