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 


List Inventory in Cheat Table

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

Joined: 16 Dec 2018
Posts: 41

PostPosted: Sat Mar 23, 2019 10:39 am    Post subject: List Inventory in Cheat Table Reply with quote

I'm playing around in Salt. I've managed to discover a pointer to my inventory structure. Through this, I've populated a subset of the item struct that shows attributes from any single item in that list, so I can effectively view & modify what I want.

The problem is that it's ungainly to update the item index and then refresh the item structure in order to view and potentially edit its attributes. My inventory currently has about 150 items, and it could potentially expand up to several hundred. The order of item indices is not so obvious that I can quickly navigate to the index of any particular item I'm searching for. It would be easier if I could just browse through a list of all of the items and pick out what I'm looking for, by name. I would have to be able to refresh this list as-needed, to account for new items that I pick up.

Despite the large size, I'd like to be able to print out a series of table entries for every item in my inventory. Whenever I pick up new items, I would just scrap and rebuild the list with a script. I'm open to alternatives, but this is the best approach I can think of. Each item entry would have 4 nested attributes. Each of the items is offset from the inventory base by +10+n*4 where n is the item index. I've already identified an inventory attribute that tells how many items are in the list, so I'll use that to denote max-n in a loop.

I'm still quite new to LUA, so I'm sure it'll take me awhile to get something working. I figured I'd post this description in case anyone with more experience would like to weigh in with some wisdom on how best to tackle this, or to provide an alternative.

Thanks!



Inventory List.png
 Description:
 Filesize:  39.53 KB
 Viewed:  4986 Time(s)

Inventory List.png


Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Mar 24, 2019 8:30 am    Post subject: Reply with quote

Yeah... I'm really not sure of a good way to handle this in CE. I mean, you can add memory records to the address list and even mark them to not be saved in the table and set the addresses but... that's a lot of records to scroll through.

CE does have a ListView which seems perfect at first but it doesn't really seem to have any support for editing columns/subitems. Guess you could have a scroll panel with a few labels and a ton of edit boxes Rolling Eyes

Though... actually you can generate and open structures with code now so you could probably do it in structure dissect fairly well.

Something like
Code:
item = createStructure('Item')
  local e = item.addElement()
  e.Name = 'ID'
  e.Offset = 0x4
  local e = item.addElement()
  e.Name = 'Name'
  e.Offset = 0x8
  e.Vartype = vtPointer
  local e = item.addElement()
  e.Name = 'Count'
  e.Offset = 0x1C
  local e = item.addElement()
  e.Name = 'Max'
  e.Offset = 0x20

local function DetermineSize() return 5 end

inv = createStructure('Inventory')
local count = DetermineSize()
  local e = inv.addElement()
  e.Name = 'Count'
  e.Vartype = vtQword
  e.Offset = 0x8
local pointersize = 4 --targetIs64Bit() and 8 or 4
for i=1,count do
  local e = inv.addElement()
  e.Name = i -- or read the name /shrug
  e.Vartype = vtPointer
  e.Offset = 0x10+i*pointersize
  e.ChildStruct = item
  print(e)
end

inv.addToGlobalStructureList()
--[[
  addToGlobalStructureList(): Add this to the list of structures for the user to select from. (Global structures will get saved to the table)
  removeFromGlobalStructureList(): Remove from the list of structures.
]]

createStructureForm('0x6584F58', 'group', inv.Name)

Though you'd want to make sure to reuse the same structure not recreate it with the same name every time if for no other reason that createStructureForm takes a name not the structure itself so can get confused if they have the same name.

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
ymiu
Cheater
Reputation: 0

Joined: 16 Dec 2018
Posts: 41

PostPosted: Sun Mar 24, 2019 9:03 am    Post subject: Reply with quote

Very cool... I didn't know I could build my own structure. You're right that the structure dissector window is a great place to do this... it keeps the table cleaner, and that gives me incentive to add excess columns to handle new items that I pick up along the way, since the offsets are predictable. That way I don't have to keep re-generating the inventory list/struct too often as it expands.

Many thanks =)
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