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 


"getMemoryRecordByDescription" for multiple target

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

Joined: 06 Jul 2015
Posts: 55
Location: Poland

PostPosted: Wed May 17, 2017 9:01 am    Post subject: "getMemoryRecordByDescription" for multiple target Reply with quote

Hello. I have a small question about lua...

Is it possible to make "getMemoryRecordByDescription()" for more than one target at same time? I want to it work like that - I have, for example, 1000 adresses with same name (description) and I want just to set same value for those 1000 adresses.

When I try, for example that lua in cheat table with many adresses with test1 description (name)
Code:

<LuaScript>
  mr1 = getAddressList().getMemoryRecordByDescription("test1")
  mr1.Active = true
  mr1.Value = 15
  </LuaScript>


The only target which will be freezed and changed value is just the first one. Every other target with same description is just ignored.

The situation is like that - I'm modding a game with Cheat Engine.
I'm changing stuff like enemies parameters, animations timing etc.

I've set tons of pointers - for example, unit parameters... There are near 800 monsters/npc in total, per every npc/monster I've set 5 pointers (action delay, turn speed, run speed, hear range, sight angle) so we have 4000 pointers here... There are more than 1000 pointers for animations start/end/action points too... So it's massive amount...

There are many duplicates of same NPC or monster, just a different variation (for example just with different appearance). For most of NPCs I want to change some parameters to same value too.

So, if the getMemoryRecordByDescription() could work for multiple targets It could save a looooooooooot of work time.

Setting hotkeys via Cheat Engine GUI is not a method here - I can set hotkey only for 1 target at same time, so for that amount of pointers... No...

I'm thinking about changing multiple pointers names to the same name at same time (It's possible) and then change their value via lua script, when the table is launched. But need to make getMemoryRecordByDescription() to work on multiple targets Wink

Hope it is possible or maybe there is some different method? Thank You.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Dark Byte
Site Admin
Reputation: 338

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

PostPosted: Wed May 17, 2017 9:42 am    Post subject: Reply with quote

Code:

local al=getAddressList()
local i
for i=0, al.Count-1 do
  if al[i].Description='test' then
  begin
    al[i].Active=true
    al[i].Value=15
  end
end


_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
FreeER
Expert Cheater
Reputation: 8

Joined: 09 Aug 2013
Posts: 196

PostPosted: Wed May 17, 2017 10:47 am    Post subject: This post has 1 review(s) Reply with quote

Another somewhat-obvious solution is that you could append a number to the description and use a loop eg

Code:
local al = getAddressList()
local name = "Description used by all: "
local numpointers = 100 -- number of pointers with the name
for i = 1, numpointers do -- assumes first is "...: 1"
  mr = al.getMemoryRecordByDescription(name .. i)
  mr.Active = true
  mr.Value = 15
end
Back to top
View user's profile Send private message
squerol
Advanced Cheater
Reputation: 1

Joined: 06 Jul 2015
Posts: 55
Location: Poland

PostPosted: Wed May 17, 2017 11:39 am    Post subject: Reply with quote

Thank You Dark Byte and FreeER for suggestions. But no success with them for me. Dunno, maybe I'm doing something wrong?
Posting screens.

Dark Byte wrote:
Code:

local al=getAddressList()
local i
for i=0, al.Count-1 do
  if al[i].Description='test' then
  begin
    al[i].Active=true
    al[i].Value=15
  end
end





FreeER wrote:
Another somewhat-obvious solution is that you could append a number to the description and use a loop eg

Code:
local al = getAddressList()
local name = "Description used by all: "
local numpointers = 100 -- number of pointers with the name
for i = 1, numpointers do -- assumes first is "...: 1"
  mr = al.getMemoryRecordByDescription(name .. i)
  mr.Active = true
  mr.Value = 15
end


Back to top
View user's profile Send private message Send e-mail Visit poster's website
Dark Byte
Site Admin
Reputation: 338

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

PostPosted: Wed May 17, 2017 2:38 pm    Post subject: This post has 1 review(s) Reply with quote

there are (at least) 2 mistakes in my script. see if you can fix it. (it may teach some lua)

hint: don't begin at the begin
and
equal is not the same as assign

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
squerol
Advanced Cheater
Reputation: 1

Joined: 06 Jul 2015
Posts: 55
Location: Poland

PostPosted: Thu May 18, 2017 9:17 am    Post subject: Reply with quote

Dark Byte wrote:
there are (at least) 2 mistakes in my script. see if you can fix it. (it may teach some lua)

hint: don't begin at the begin
and
equal is not the same as assign


Ohhhhh, nice trick Dark Byte Embarassed

Thanks for hints anyway, it's fixed now I think:

Code:

local al=getAddressList()
local i
for i=0, al.Count-1 do
  if al[i].Description=='test' then
    al[i].Active=true
    al[i].Value=15
  end
end


Thank You very much for script, You've saved me shitload of time Wink

Your script even find targets hidden deep in multiple groups, nice.

About learning lua - I don't even want to be honest. When I try to recall my IT highschool and "very basics of basics" of c++, javascript, php, html and mysql and that I couldn't pass that school without cheating every test, I think it's hopeless even to try it Confused
Back to top
View user's profile Send private message Send e-mail Visit poster's website
FreeER
Expert Cheater
Reputation: 8

Joined: 09 Aug 2013
Posts: 196

PostPosted: Thu May 18, 2017 10:45 am    Post subject: Reply with quote

Glad you got DB's working, as for mine it depends on having a setup like this:



Notice that the records are named "Test 1", "Test 2", etc. and that the name that the number is appended to includes a space at the end and has the same case. Also that the address list starts at "Test 1" and ends at "Test 6" and the for loop starts with i = 1 and numpointers is 6 (not 100 because there aren't 100 records to change).

A simple fix for the error you saw is to nest the code that changes the memory record in an if statement that checks if mr is "true" eg.

Code:

for i = 1, numpointers do
  mr = al.getMemoryRecordByDescription(name .. i)
  if mr then -- only if the memory record actually exists
    mr.Active = true
    mr.Value = 15
  end
end


So it won't cause an error by trying to do something to a script that doesn't exist. But that won't make the script work if it's not setup correctly and it's unnecessary if it is setup correctly (it just "hides" the error).

As for learning lua, if you can at least kind of understand how/why these two scripts work then you can learn lua, if you want to.
Back to top
View user's profile Send private message
squerol
Advanced Cheater
Reputation: 1

Joined: 06 Jul 2015
Posts: 55
Location: Poland

PostPosted: Sat May 20, 2017 3:41 am    Post subject: Reply with quote

Thank You
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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