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 


Create Records

 
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: Thu Apr 20, 2017 8:57 pm    Post subject: Create Records Reply with quote

Code:
al=getAddressList()
name_address = 0x2a7d60f
name_offset = 0x462
for i =0,127 do
whichHero = trainer.Data.Characters[i]
mr = al.createMemoryRecord()
mr.Type = vtString,10
mr.Address = string.format("%x",(name_address + name_offset*i))
mr.Description = readString(mr.Address,10)
end


I've run into a couple of issues here, using Ver 6.3
mr.Address they are all correct
mr.Type isn't right they are all zero length
mr.Description all are Plugin Address

What do I need to change?
Back to top
View user's profile Send private message Yahoo Messenger
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Thu Apr 20, 2017 9:24 pm    Post subject: Reply with quote

bknight2602 wrote:
What do I need to change?

Your version of CE. From my perspective, you're being somewhat egotistical by expecting to get support for outdated software.

Regardless, if you look at main.lua, you'll see why the string's size is always 0:
Code:
MemoryRecord Class:
...
Type: ValueType - The variable type of this record. See vtByte to vtCustom
    If the type is vtString then the following properties are available:
     String.Size: Number of characters in the string
     String.Unicode: boolean
...
(this is the main.lua of CE 6.6, it could be different in 6.3)

Instead of putting ",10" after vtString, assign 10 to the String.Size property of the memory record (i.e. mr.String.Size = 10).

As for the description, that code seems to work fine in CE 6.6. I'd guess it's a bug in 6.3.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Fri Apr 21, 2017 6:47 am    Post subject: Reply with quote

Description property was fixed in later versions - bug was fixed on 11 Aug 2013 - https://github.com/cheat-engine/cheat-engine/commit/a0e18e68a95d9a26762a21bdcee012fdc1c2e9ed
setDescription method should work.


So, use this:
Code:
mr.setDescription(readString(mr.Address,10) )



or use newer CE version.

_________________
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Fri Apr 21, 2017 9:32 am    Post subject: Reply with quote

ParkourPenguin wrote:
bknight2602 wrote:
What do I need to change?

Your version of CE. From my perspective, you're being somewhat egotistical by expecting to get support for outdated software.

Regardless, if you look at main.lua, you'll see why the string's size is always 0:
Code:
MemoryRecord Class:
...
Type: ValueType - The variable type of this record. See vtByte to vtCustom
    If the type is vtString then the following properties are available:
     String.Size: Number of characters in the string
     String.Unicode: boolean
...
(this is the main.lua of CE 6.6, it could be different in 6.3)

Instead of putting ",10" after vtString, assign 10 to the String.Size property of the memory record (i.e. mr.String.Size = 10).


Tried that and didn't work, but it seems reasonable, perhaps a bug in 6.3 as in the Description



mgr.inz.Player wrote:
Description property was fixed in later versions - bug was fixed on 11 Aug 2013 - https://github.com/cheat-engine/cheat-engine/commit/a0e18e68a95d9a26762a21bdcee012fdc1c2e9ed
setDescription method should work.


So, use this:
Code:
mr.setDescription(readString(mr.Address,10) )



or use newer CE version.


In the train of thought from another string in which you posted getDescription(), I thought I tried that, however, using your suggestion that worked and the new records have what I was attempting except the size of the string/text. See above comment mr.String.Size = 10 resulted in an error attempting to index a nil value(String)
Back to top
View user's profile Send private message Yahoo Messenger
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Fri Apr 21, 2017 9:43 am    Post subject: Reply with quote

There's a memoryrecord_string_setSize function defined in the same file at the time of that commit. Try using that.

Again, I would recommend you update CE to the latest version. You'll eventually get left behind if you continue using 6.3. The sooner you update everything, the easier it will be.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Fri Apr 21, 2017 12:38 pm    Post subject: Reply with quote

Hopefully opening the table with 6.6 doesn't prevent opening/running with 6.3, but
Code:
al=getAddressList()
name_address = 0x294d60f
name_offset = 0x462
for i =0,127 do
  whichHero = trainer.Data.Characters[i]
  al = getAddressList()
  for x = 0, al.Count-1 do
    whichRec = al.MemoryRecord[x]
      if al.Description == whichRec then
      if x > 5541 then
      whichRecord.deleteMemoryRecord()
      end
      end
  end
end

Results Error:in attempt to call a nil value (field 'deleteMemoryRecord')
How does one delete the record?
For those wondering, the createRecord added records, some of which are duplicates, and I wish to delete the duplicates, but just the records added with the create procedure(at the end x >=5541)
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Fri Apr 21, 2017 1:24 pm    Post subject: Reply with quote

whichRecord.destroy()
_________________
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
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Fri Apr 21, 2017 2:27 pm    Post subject: Reply with quote

That's not fair!!
But it didn't run, got tp the first duplicate record and error

Error:TTreeNodes.GetNodeFromIndex Index 5669 out of bounds (Count=5669)
That's probably accurate, so I guess I'll have to delete them manually, unless there is another suggestion.
Back to top
View user's profile Send private message Yahoo Messenger
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Fri Apr 21, 2017 2:42 pm    Post subject: Reply with quote

you are messing many things:

bknight2602 wrote:
Hopefully opening the table with 6.6 doesn't prevent opening/running with 6.3, but
Code:
al=getAddressList()
name_address = 0x294d60f
name_offset = 0x462
for i =0,127 do
  whichHero = trainer.Data.Characters[i]
  al = getAddressList()
  for x = 0, al.Count-1 do
    whichRec = al.MemoryRecord[x]
      if al.Description == whichRec then
      if x > 5541 then
      whichRecord.deleteMemoryRecord()
      end
      end
  end
end



al object doesn't have Description property.

_________________
Back to top
View user's profile Send private message MSN Messenger
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Fri Apr 21, 2017 3:08 pm    Post subject: Reply with quote

Also, the for loop evaluates the upper boundary expression only once. If the control expressions represent an index in a container, no items should be added to or removed from the container within the for loop. Otherwise, the for loop will either not iterate over all the items or try to index a value that no longer exists.

Deleting a memory record will modify the upper boundary of the address list. In the for loop in your code, this will eventually cause an access violation because the address list is now shorter than it was when the for loop started (i.e. the only time the expression al.Count-1 was evaluated).

Iterating over the address list in the opposite direction using a for loop would work.
Code:
for i = al.Count - 1, 0, -1 do
  -- code...
  al[i].destroy()
end

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Fri Apr 21, 2017 3:20 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Also, the for loop evaluates the upper boundary expression only once. If the control expressions represent an index in a container, no items should be added to or removed from the container within the for loop. Otherwise, the for loop will either not iterate over all the items or try to index a value that no longer exists.

Deleting a memory record will modify the upper boundary of the address list. In the for loop in your code, this will eventually cause an access violation because the address list is now shorter than it was when the for loop started (i.e. the only time the expression al.Count-1 was evaluated).

Iterating over the address list in the opposite direction using a for loop would work.
Code:
for i = al.Count - 1, 0, -1 do
  -- code...
  al[i].destroy()
end

I thought I was taking care of the upper bound, by resetting al=getAddressList()
Code:
al=getAddressList()
name_address = 0x294d60f
name_offset = 0x462
for i =0,127 do
  whichHero = trainer.Data.Characters[i]
  al = getAddressList()
  numb = 0
  for x = 0, al.Count-1 do
    whichRecord = al.MemoryRecord[x]
      if whichRecord.Description == whichHero then
        numb = numb +1
        if x >= 5541 and numb >= 2 then
          print(x .. " " .. whichRecord.Description)
          whichRecord.destroy()
        end
      end
  end
end

line #6, but working backwards might have been better and that statement might have been in the wrong position.
Back to top
View user's profile Send private message Yahoo Messenger
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Fri Apr 21, 2017 3:29 pm    Post subject: Reply with quote

It would be easier if you use "header" memory record, then append memory records there, those you want to delete in the future.
_________________
Back to top
View user's profile Send private message MSN 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
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