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 


.tvStructureView.Selected err in v7.6 [Solved]

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

Joined: 20 Jul 2017
Posts: 206

PostPosted: Tue Sep 09, 2025 11:25 pm    Post subject: .tvStructureView.Selected err in v7.6 [Solved] Reply with quote

I'm using following code:

local entry = structForm.tvStructureView.Selected
local struct = integerToUserData(entry.Parent.Data)
local structelement = struct.Element[entry.Index]

Using "any" pre-7.6 version gives no problems, but with 7.6 I get following error:
Error:[string "
..."]:1340: attempt to index a nil value (local 'struct')


> If there is a "workaround" - such as a different way to obtain this info - then do tell. This code is used in a feature, adding an additional 'context_fn' while dissecting a structure.


some more details:
a. structForm is either collected this way:
local structForm = enumStructureForms()[1]
if (structForm == nil) then return end
OR
b. passed on via:
registerFormAddNotification(function(form)

c. and [structForm] is known/correct


Last edited by paul44 on Sat Sep 13, 2025 11:12 am; edited 1 time in total
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: Tue Sep 09, 2025 11:36 pm    Post subject: Reply with quote

structElement,path=structForm.getSelectedStructElement()
_________________
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
paul44
Expert Cheater
Reputation: 2

Joined: 20 Jul 2017
Posts: 206

PostPosted: Wed Sep 10, 2025 10:44 am    Post subject: only in basestruct Reply with quote

just tested: this works fine on elements in the basestruct, but unfortunately - and this feature is mostly used inside substructures - it still gives that error.
> see [ https://ibb.co/S4BWp2qz ]

To get an idea: UE games manage inventoryItems in ArrayStructs for example, whereby each item is identified by its uniqueID. So, while researching, you'd obviously want to know what that item is.

And yes, one can always create a new 'basestructure'. but take my word for it, in many cases pretty "counterproductive" (the image is a good example: you just want to know if you are in the "right place" or not...)
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: Wed Sep 10, 2025 12:46 pm    Post subject: Reply with quote

check the code at line 1379 and adjust it so that struct isn't needed and you can get the element directly.

or to get the struct get the element first and then get the element.Owner which is the struct the element is in.

anyhow, in next version 7.6.2 I've published element and childnodestruct in the TStructureTreeNode itself

_________________
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
paul44
Expert Cheater
Reputation: 2

Joined: 20 Jul 2017
Posts: 206

PostPosted: Sat Sep 13, 2025 3:35 am    Post subject: element.Value needed... Reply with quote

I do not need the struct perse, but i do need to 'readInteger' the value at a specific address...
I wrote included script some time back (with CE assistance ofc ~ this is not my kind of "level coding") for a similar approach

Some info: [ https://ibb.co/album/KDq2NT ] (check images from last to 1st)

1. the 'while entry.parent' builds the address_path to the selected Element
2. the next 2 pics show a 7.3 collection
3. the 4rd pic shows 7.6 collection: the final (?) offset is wrong here
4. 5th pic: exact same location with 7.3 (or "any" vs below 7.6)

Bottomline: I need the address of that selected Element, so i can grab its value.

btw: if i can get it working for the present vs, then great. if not, no (serious Razz) harm done.
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: Sat Sep 13, 2025 4:18 am    Post subject: Reply with quote

try this:
Code:

function getSelectedElementAddress(f)
  --f is a structure dissect form

  local a=f.getSelectedStructElement()


  local list={}
  local n=f.tvStructureView.Selected
  while n do
    table.insert(list,n)
    n=n.parent
  end

  table.remove(list,#list)

  local address=nil
  for i=0,f.columnCount-1 do
    if f.Column[i].focus then
      address=f.Column[i].Address
      break
    end
  end

  if address==nil then error('the focused column has no address') end

  local s=f.mainStruct
  --f.mainStruct.Element[list[i].Index]
  for i=#list,2,-1 do
    local structindex=list[i].Index
    local entry=s[structindex]
    s=entry.ChildStruct

    address=readPointer(address+entry.offset)
    if address==nil then return nil end --nothing to get after this. bad path

    if s==nil then error('pointer without child') end
  end

  local structindex=list[1].Index
  local b=s[structindex]

  if a~=b then
    error('something went wrong during the path traversal')
  end

  return address+b.offset
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
paul44
Expert Cheater
Reputation: 2

Joined: 20 Jul 2017
Posts: 206

PostPosted: Sat Sep 13, 2025 11:12 am    Post subject: solved. Reply with quote

yep, that works ! thx a mil.

Since 'getSelectedStructElement()' got introduced in v7.4, we keep both versions for backward compatibility...
cheers

-EDIT-
Minor correction: (else it always takes 1st column)
if f.Column[i].Focused then
address=f.Column[i].Address
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