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 


Updating structure offsets

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

Joined: 14 Jan 2019
Posts: 87

PostPosted: Thu Apr 11, 2024 8:25 am    Post subject: Updating structure offsets Reply with quote

Is there any option to temporary disable structure updates? (there is only beginUpdate() resp. end to make it even faster but i'd like to ... stop and continue)
Else is there any convinient method to update structure offsets rather than ... thinking a about a rly complex method for the correct logical order.

What I actually have is a table read from memory that I try to match with my structure, but it's a complete mess (not as simple as example below) so I can only check on IDs. But the problem is, that once I go through the table and update an offset the table indexes wont match the ones in the struct so .... uff.

Easy example:
Code:
--create structure from 0 to 10
local struct=createStructure("test")
for i=0,10 do
  local el = struct.addElement()
  el.Name=tostring(i)
  el.Offset=i*16
  el.VarType=2 --vtDword
  el.DisplayMethod='dtSignedInteger'
  print(i,el.Name,el.Offset)
end
--change offsets in reverse order
for i=0,10 do
  local el = struct.Element[i]
  el.Offset=(10-i)*16
  print(i,el.Name,el.Offset)
end
struct.addToGlobalStructureList()
createStructureForm(0, nil, "test")
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Thu Apr 11, 2024 10:06 am    Post subject: Reply with quote

create a lua table to hold all the elements and then go through there
_________________
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
salumor
Advanced Cheater
Reputation: 0

Joined: 14 Jan 2019
Posts: 87

PostPosted: Thu Apr 11, 2024 10:19 am    Post subject: Reply with quote

You mean I simply have to make sure to have everything I need in table, destroy that structure or elements (and if wanted create a new one)?
So there is no way around structures auto-resorting based on offsets?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Thu Apr 11, 2024 10:46 am    Post subject: This post has 1 review(s) Reply with quote

just a lua table. {}

put e into a table after creating the elements and when you wish to mass edit stuff use that table for indexes

in the example:
Code:

--create structure from 0 to 10
local t
local struct=createStructure("test")
for i=0,10 do
  local el = struct.addElement()
  el.Name=tostring(i)
  el.Offset=i*16
  el.VarType=2 --vtDword
  el.DisplayMethod='dtSignedInteger'
  t[i+1]=el
  print(i,el.Name,el.Offset)
end
--change offsets in reverse order
for i=0,10 do
  local el = t[i+1]
  el.Offset=(10-i)*16
  print(i,el.Name,el.Offset)
end
struct.addToGlobalStructureList()
createStructureForm(0, nil, "test")

_________________
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
salumor
Advanced Cheater
Reputation: 0

Joined: 14 Jan 2019
Posts: 87

PostPosted: Thu Apr 11, 2024 11:39 am    Post subject: Reply with quote

Ah ok. Thanks, now I got it!

I do wonder how it works, that structures are updated and a table referencing not. But yeah, this is what I wanted.

(for anyone reading it too: ofc its "local t={}")
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