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 


Incrementing base address by some multiple of x in lua?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Mon May 09, 2016 8:39 pm    Post subject: Reply with quote

Code:
local list = getAddressList()
local offset = 0x00F00000
for i=1,10 do
  local rec = list.getMemoryRecordByDescription("name "..i)
  if rec == nil then
    break
  end
  local addr = string.format("game.exe+%X", offset)
  rec.Address = addr
  offset = offset + 0x10
end
Back to top
View user's profile Send private message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Tue May 10, 2016 11:13 am    Post subject: Reply with quote

Zanzer wrote:
Code:
local list = getAddressList()
local offset = 0x00F00000
for i=1,10 do
  local rec = list.getMemoryRecordByDescription("name "..i)
  if rec == nil then
    break
  end
  local addr = string.format("game.exe+%X", offset)
  rec.Address = addr
  offset = offset + 0x10
end


Thanks, this is very helpful. Smile
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Tue May 10, 2016 8:59 pm    Post subject: Reply with quote

Code:
local list = getAddressList()
local combo = UDF1.CEComboBox1
local items = combo.Items
local index = combo.ItemIndex
local compare = nil
if index >= 0 then
  compare = items[index]
end
combo.clear()
for i = 1, 3 do
  local record = list.getMemoryRecordByDescription("Name "..i)
  local value = record.Value
  if value ~= nil and #value > 0 then
    items.add(value)
    if value == compare then
      combo.ItemIndex = items.Count - 1
    end
  end
end
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Wed May 11, 2016 7:13 pm    Post subject: Reply with quote

When you build the items list, you can create a records list to go with it.
Then you can get the record with: combo.record[combo.ItemIndex]
Code:
local list = getAddressList()
local combo = UDF1.CEComboBox1
local items = combo.Items
local index = combo.ItemIndex
local compare = nil
if index >= 0 then
  compare = items[index]
end
combo.clear()
combo.record = {} -- declare an empty array
for i = 1, 3 do
  local record = list.getMemoryRecordByDescription("Name "..i)
  local value = record.Value
  if value ~= nil and #value > 0 then
    local index = items.Count
    items.add(value)
    items.record[index] = record -- populate your array with each record
    if value == compare then
      combo.ItemIndex = index
    end
  end
end
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Fri May 13, 2016 6:05 pm    Post subject: Reply with quote

Code:
autoAssemble(AssemblyLock..[[
nop
]])
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