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 


Addresslist addresses, values, Descriptions
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sun Jan 23, 2022 2:48 pm    Post subject: Addresslist addresses, values, Descriptions Reply with quote

I' running a code on one of my tables
Code:

addresslist = getAddressList()
for x = 0,addresslist.Count-1
do
test = addresslist,x
print(test)
end


The output is the same record.

If I change the print to print(x), the output is the number of records, so why is the record the same?
What I am ultimately seeking, after my question is to output the table record addresses, descriptions and values.
Back to top
View user's profile Send private message Yahoo Messenger
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Sun Jan 23, 2022 3:05 pm    Post subject: Reply with quote

That's because you're printing the iterator and not the entry of the addresslist, not to mention that you have used a comma instead of the period character as the accessor.
Code:

local al = getAddressList()

for x = 0, al.Count - 1 do
  local mr = al.getMemoryRecord(x)
  if mr ~= nil then
    print('description:\t' .. mr.description .. '\nvalue:\t\t' .. mr.value .. '\naddress:\t\t' .. mr.address)
  else
   print('No memory records')
  end
end
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sun Jan 23, 2022 3:37 pm    Post subject: Reply with quote

Yes, I did use a comma. The output is great except I guess I should have said the table address and not the game address, which are known. The reason is there is code that I am debugging, and the output is the table address.
Back to top
View user's profile Send private message Yahoo Messenger
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Sun Jan 23, 2022 3:55 pm    Post subject: Reply with quote

Okay, it's a little unclear exactly what it is you want, but I will explain here what's happening with your code.
Code:

addresslist = getAddressList()      // Assign the handle of getAddressList() into the variable addresslist
for x = 0,addresslist.Count-1       // Set x as the iterator from 0 to the addresslist count - 1
do
test = addresslist,x                // Assign the handle of addresslist to test. ",x" does nothing. "x" stores the iteration of the loop, in your case it is 0 (first iteration)
print(test)                         // Prints the value of test to the log
end   


It's not printing a record but the handle to the addresslist.
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sun Jan 23, 2022 4:14 pm    Post subject: Reply with quote

Ok, for example the game addresses are

49ee3e (first address in table)
...
4a0fc2
...
4a105b(Last address in table)
While debugging code I get outputs

086C2BE0
0D13DAF0

Is that clearer?
Back to top
View user's profile Send private message Yahoo Messenger
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Sun Jan 23, 2022 4:24 pm    Post subject: Reply with quote

Have I not explained that already? It's printing the handle of the addresslist to the console and not the memory record. The code I posted will do what you want to do. Loop through every memory record in the table and print it to the console.

See below:
LeFiXER wrote:

Code:

local al = getAddressList()

for x = 0, al.Count - 1 do
  local mr = al.getMemoryRecord(x)
  if mr ~= nil then
    print('description:\t' .. mr.description .. '\nvalue:\t\t' .. mr.value .. '\naddress:\t\t' .. mr.address)
  else
   print('No memory records')
  end
end
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Sun Jan 23, 2022 4:28 pm    Post subject: Reply with quote

bknight2602 wrote:
Ok, for example the game addresses are

49ee3e (first address in table)
...
4a0fc2
...
4a105b(Last address in table)
While debugging code I get outputs

086C2BE0
0D13DAF0

Is that clearer?


Like LeFiXER said, "test = addresslist,x" it the same as "test = addresslist". e.g. "test1, test2 = 'string 1', 'string 2'" just sets two variables at once. I think you are getting confused with a no parentheses notation, i.e. "print 'test'" note that there is no comma. I would definitely say use parentheses to help stop any confusion, and in this case you actually need to use square brackets for it to work this way.

Code:
test = addresslist[x]

or
Code:
test = addresslist.getMemoryRecord(x)

_________________
Back to top
View user's profile Send private message Visit poster's website
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sun Jan 23, 2022 4:38 pm    Post subject: Reply with quote

LeFiXER wrote:
Have I not explained that already? It's printing the handle of the addresslist to the console and not the memory record. The code I posted will do what you want to do. Loop through every memory record in the table and print it to the console.

See below:
LeFiXER wrote:

Code:

local al = getAddressList()

for x = 0, al.Count - 1 do
  local mr = al.getMemoryRecord(x)
  if mr ~= nil then
    print('description:\t' .. mr.description .. '\nvalue:\t\t' .. mr.value .. '\naddress:\t\t' .. mr.address)
  else
   print('No memory records')
  end
end


Yes it certainly does, print game addresses which are known. I guess I can't explain any further I'm seeking a different set of addresses.
Thanks for your time and effort.
Back to top
View user's profile Send private message Yahoo Messenger
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Sun Jan 23, 2022 4:53 pm    Post subject: Re: Addresslist addresses, values, Descriptions Reply with quote

bknight2602 wrote:
What I am ultimately seeking, after my question is to output the table record addresses, descriptions and values.
...
I guess I can't explain any further I'm seeking a different set of addresses.


The table holds the memory records that have been placed into the cheat table already. You can't access them if they don't exist. Without further details of what you're trying to achieve, what you have, what you've tried etc... no one here can help.
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Sun Jan 23, 2022 5:16 pm    Post subject: This post has 1 review(s) Reply with quote

bknight2602 wrote:
LeFiXER wrote:
Have I not explained that already? It's printing the handle of the addresslist to the console and not the memory record. The code I posted will do what you want to do. Loop through every memory record in the table and print it to the console.

See below:
LeFiXER wrote:

Code:

local al = getAddressList()

for x = 0, al.Count - 1 do
  local mr = al.getMemoryRecord(x)
  if mr ~= nil then
    print('description:\t' .. mr.description .. '\nvalue:\t\t' .. mr.value .. '\naddress:\t\t' .. mr.address)
  else
   print('No memory records')
  end
end


Yes it certainly does, print game addresses which are known. I guess I can't explain any further I'm seeking a different set of addresses.
Thanks for your time and effort.


Those aren't game addresses, here's an example. Open CE and don't attach to anything just open the lua engine window (Ctrl+m then Ctrl+L). Then paste this in and hit execute.
Code:
print(tostring(print))

You'll get an output like this.
Code:
function: 0000000000651710


And another example.
Code:
print(tostring({ }))

You'll get an output like this.
Code:
table: 000000001017F490


And with "AddressList".
Code:
print(tostring(AddressList))

You'll get an output like this.
Code:
userdata: 000000000467B418


This has nothing to do with CE, it's just how lua works. It's an address for the object; i.e. print function, table, and the CE address list. You might want to start with some Lua tutorials. And I'd even say do some with just lua without CE.

https://www.tutorialspoint.com/lua/index.htm

_________________
Back to top
View user's profile Send private message Visit poster's website
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sun Jan 23, 2022 5:42 pm    Post subject: Reply with quote

I resisted posting this since everyone will bang on me for not using the "proper" coding techniques, which I sadly have not learned. However,
Code:

 self.listview = createListView(self.form)
 setProperty(self.listview, 'ViewStyle', 'vsReport')
 setProperty(self.listview, 'RowSelect', 'True')
 setProperty(self.listview, 'ReadOnly', 'True')
 setProperty(self.listview, 'HideSelection', 'False')
 self.listview.top = 165;
 self.listview.width = 130;
 self.listview.left = 165;
 self.listview.height = 210;
 self.listview.onClick = function (sender)
                              local char
                              if (trainer.characters_rg.ItemIndex >= 0 ) then
                                 char = strings_getString(self.characters_rg.getItems(), self.characters_rg.ItemIndex);
                              end
                              local row_1 = sender.getItems().getItem(sender.getItemIndex()); -- Level
 print(row_1)
                              local row_2 = strings_getString(row_1.getSubItems(),0) + 0; -- Exp
 print(row_2)
                              if (char and row_1 and row_2) then
                                 local address_1 = addresslist_getMemoryRecordByDescription(getAddressList(), char ..'Exp');
 print(address_1)
                                 if (address_1) then
                                    memoryrecord_setValue(address_1, row_2 - math.floor(row_2/65536) * 65536)
                                 end
                              end
                           end


The list view contains two columns of data, Level and Exp.
When the desired row lvl, exp, is selected the exp is supposed to be set at its desired game location. It does not.
Back to top
View user's profile Send private message Yahoo Messenger
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Sun Jan 23, 2022 5:50 pm    Post subject: Reply with quote

bknight2602 wrote:
I resisted posting this since everyone will bang on me for not using the "proper" coding techniques, which I sadly have not learned. However,
Code:

 self.listview = createListView(self.form)
 setProperty(self.listview, 'ViewStyle', 'vsReport')
 setProperty(self.listview, 'RowSelect', 'True')
 setProperty(self.listview, 'ReadOnly', 'True')
 setProperty(self.listview, 'HideSelection', 'False')
 self.listview.top = 165;
 self.listview.width = 130;
 self.listview.left = 165;
 self.listview.height = 210;
 self.listview.onClick = function (sender)
                              local char
                              if (trainer.characters_rg.ItemIndex >= 0 ) then
                                 char = strings_getString(self.characters_rg.getItems(), self.characters_rg.ItemIndex);
                              end
                              local row_1 = sender.getItems().getItem(sender.getItemIndex()); -- Level
 print(row_1)
                              local row_2 = strings_getString(row_1.getSubItems(),0) + 0; -- Exp
 print(row_2)
                              if (char and row_1 and row_2) then
                                 local address_1 = addresslist_getMemoryRecordByDescription(getAddressList(), char ..'Exp');
 print(address_1)
                                 if (address_1) then
                                    memoryrecord_setValue(address_1, row_2 - math.floor(row_2/65536) * 65536)
                                 end
                              end
                           end


The list view contains two columns of data, Level and Exp.
When the desired row lvl, exp, is selected the exp is supposed to be set at its desired game location. It does not.


"address_1" is a memory record. So like it's been stated over and over already you are print the handle not the address property. To do that try this.
Code:
print(address_1.Address)

_________________
Back to top
View user's profile Send private message Visit poster's website
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sun Jan 23, 2022 6:32 pm    Post subject: Reply with quote

TheyCallMeTim13 wrote:
bknight2602 wrote:
I resisted posting this since everyone will bang on me for not using the "proper" coding techniques, which I sadly have not learned. However,
Code:

 self.listview = createListView(self.form)
 setProperty(self.listview, 'ViewStyle', 'vsReport')
 setProperty(self.listview, 'RowSelect', 'True')
 setProperty(self.listview, 'ReadOnly', 'True')
 setProperty(self.listview, 'HideSelection', 'False')
 self.listview.top = 165;
 self.listview.width = 130;
 self.listview.left = 165;
 self.listview.height = 210;
 self.listview.onClick = function (sender)
                              local char
                              if (trainer.characters_rg.ItemIndex >= 0 ) then
                                 char = strings_getString(self.characters_rg.getItems(), self.characters_rg.ItemIndex);
                              end
                              local row_1 = sender.getItems().getItem(sender.getItemIndex()); -- Level
 print(row_1)
                              local row_2 = strings_getString(row_1.getSubItems(),0) + 0; -- Exp
 print(row_2)
                              if (char and row_1 and row_2) then
                                 local address_1 = addresslist_getMemoryRecordByDescription(getAddressList(), char ..'Exp');
 print(address_1)
                                 if (address_1) then
                                    memoryrecord_setValue(address_1, row_2 - math.floor(row_2/65536) * 65536)
                                 end
                              end
                           end


The list view contains two columns of data, Level and Exp.
When the desired row lvl, exp, is selected the exp is supposed to be set at its desired game location. It does not.


"address_1" is a memory record. So like it's been stated over and over already you are print the handle not the address property. To do that try this.
Code:
print(address_1.Address)

The output is 0D13DAF0 as I posted earlier, the game address is 4a0fc3.
row_1 prints as 08B0BAA0 row_2 prints as 99 which is the correct value in the listview.
Back to top
View user's profile Send private message Yahoo Messenger
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Mon Jan 24, 2022 5:23 am    Post subject: Reply with quote

bknight2602 wrote:

The output is 0D13DAF0 as I posted earlier, the game address is 4a0fc3.
row_1 prints as 08B0BAA0 row_2 prints as 99 which is the correct value in the listview.


Code:

local address_1 = addresslist_getMemoryRecordByDescription(getAddressList(), char ..'Exp');

This is your problem. As you can see the function addresslist_getMemoryRecordByDescription is being passed the addresslist, which is a handle to the addresslist object and not a string which the function expects. The following part ", char .. 'Exp'" is disregarded because the aforementioned function requires only one argument.

Code:

getMemoryRecordByDescription(description): returns a MemoryRecord object

As you can see, it requires one argument to return the MemoryRecord object.

Code:

getAddressList() : Returns the cheat table addresslist object

Like so, the getAddressList() function returns the cheat table's addresslist object.
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Mon Jan 24, 2022 10:52 am    Post subject: Reply with quote

LeFiXER wrote:
bknight2602 wrote:

The output is 0D13DAF0 as I posted earlier, the game address is 4a0fc3.
row_1 prints as 08B0BAA0 row_2 prints as 99 which is the correct value in the listview.


Code:

local address_1 = addresslist_getMemoryRecordByDescription(getAddressList(), char ..'Exp');

This is your problem. As you can see the function addresslist_getMemoryRecordByDescription is being passed the addresslist, which is a handle to the addresslist object and not a string which the function expects. The following part ", char .. 'Exp'" is disregarded because the aforementioned function requires only one argument.

Code:

getMemoryRecordByDescription(description): returns a MemoryRecord object

As you can see, it requires one argument to return the MemoryRecord object.

Code:

getAddressList() : Returns the cheat table addresslist object

Like so, the getAddressList() function returns the cheat table's addresslist object.

Well would you offer a solution to allow the exp to update the proper address?
In the first Hero 1 with Hero 1exp as the experience. The rest are
Hero 2
Hero 3
Hero 4
All with similar experience record descriptions.
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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