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 


Auotomaticly reading multiple layers of a branching table?

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

Joined: 29 Nov 2008
Posts: 918

PostPosted: Wed Oct 30, 2013 10:13 pm    Post subject: Auotomaticly reading multiple layers of a branching table? Reply with quote

For the borderlands cheat im working on i have a big branching array of values to read and im trying to figure out the best method to do it. The idea i had was a looping for statement and creating a table array as it progresses to try and keep track of what has been done. I'm sure there is a more efficient way of doing it so i'm asking here first before i start trying to code the odd way i had planned.

To give an idea of whats going on, this is a basic idea of how a chain will look.


Code:
Normal Enemy:
  Guns:
    Legendary:
      Launchers:
      SMGS:
    Rare:
      Pistols:
      Assaults:
    Crap:
      Shotguns:
  Shields:
    Legendary:
      Amp:
    Rare:
      Amp:
    Crap:
      Amp:
  Money:


Setting the loop up to auto read the names and data is easy enough, just getting the loop itself setup to where it goes down each chain and sets it up is the part im getting stuck on. One idea i had was setting up a different thread for each level down but im not sure how good of a idea that is. The way i planned on having the loop stop was if the count value for the next level is 0 so that if should be easy enough to do. Any perspective would be great Smile
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Thu Oct 31, 2013 4:48 am    Post subject: Reply with quote

I'm not really sure what you wish to do . In what kind of format is that array stored? Just a stringlist ? Or a lua table? Or a cheat engine table/treeview

Have you tried using a recursive function to walk through the data?

In case of text
e.g something like this: (contains bugs but I hope you get the idea)
Code:

function getCurrentLevel(data, line)
  --get the level (e.g every 2 spaces is a level)
end

function getData(data,line)
  --parse the data from the line
 
end

function f(data, linecount, currentlevel, line, tableentry)
  local i=0
  while line<linecount do
    local level=getCurrentLevel(data, line)
    if level<currentlevel then return line --reached end of current leaf

    if level>currentlevel then --enter a new leaf
      tableentry[i]={}
      line=f(data, linecount, currentlevel+1, line, tableentry[i])
    else
      --level==currentlevel (same leaf)
      tableentry[i]=getData(data, line)
      line=line+1 
    end
    i=i+1
 
 
  end

---
  parseddata={}
  f(data, 1000, 0, 0, parseddata)

_________________
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
pox911
Grandmaster Cheater
Reputation: 28

Joined: 29 Nov 2008
Posts: 918

PostPosted: Thu Oct 31, 2013 9:24 am    Post subject: Reply with quote

i'm not sure if i'm following that code correctly or not. The data im sorting through is all in different objects in the unreal engine but they all link to each other in a systematic way.


Im throwing this example together off the top of my head but i had an idea for something along the lines of this and was wondering how viable it would be. I'm being a bit sloppy with the example but i hope i get my idea out.

Code:
function TableSearch()
{scan function here to get base address and count for first layer}
  For i = 1, BaseCount do
    {create basic code entry for first layer}
    ParentAddr = BaseAddress
    DataLoop(ParentAddr,Next Level Pointer,any extra info i think of)
  end
end

DataLoop(Parent,MiscInfo)
  if   levelCount > 0 then
     {create code data for this level}
  for i=1, next level count
    createThread(recall this function same functio again with the info for the next level)
  end
end


It's not the most gracefull aproach but im having trouble thinking of another way to do it nicely to get all branching layers added nicely. When going down the chain there is no immediate reference to the level above it and the while statements i was thinking of before would only go down one level and not hit them all.
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