View previous topic :: View next topic |
Author |
Message |
paul44 Expert Cheater
Reputation: 2
Joined: 20 Jul 2017 Posts: 206
|
Posted: Tue Sep 09, 2025 11:25 pm Post subject: .tvStructureView.Selected err in v7.6 [Solved] |
|
|
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 |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25796 Location: The netherlands
|
Posted: Tue Sep 09, 2025 11:36 pm Post subject: |
|
|
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 |
|
 |
paul44 Expert Cheater
Reputation: 2
Joined: 20 Jul 2017 Posts: 206
|
Posted: Wed Sep 10, 2025 10:44 am Post subject: only in basestruct |
|
|
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 |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25796 Location: The netherlands
|
Posted: Wed Sep 10, 2025 12:46 pm Post subject: |
|
|
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 |
|
 |
paul44 Expert Cheater
Reputation: 2
Joined: 20 Jul 2017 Posts: 206
|
Posted: Sat Sep 13, 2025 3:35 am Post subject: element.Value needed... |
|
|
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 ) harm done. |
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25796 Location: The netherlands
|
Posted: Sat Sep 13, 2025 4:18 am Post subject: |
|
|
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 |
|
 |
paul44 Expert Cheater
Reputation: 2
Joined: 20 Jul 2017 Posts: 206
|
Posted: Sat Sep 13, 2025 11:12 am Post subject: solved. |
|
|
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 |
|
 |
|