|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Devon999 Newbie cheater Reputation: 0
Joined: 03 May 2022 Posts: 23
|
Posted: Wed May 25, 2022 3:05 pm Post subject: How to use an asm var in AA $lua string replace? (solved!) |
|
|
In AA script, how do I edit this lua line to call the ASM variable named HP that I set, and have it go in place of the "NewWord" text? I want to replace the found string with what's typed into the hp variable in my addresslist.
replaceString("OldWord","NewWord",true)
Below is the whole code I'm using. It all works but I just don't know how to use an ASM variable within that LUA line...
Code: | [ENABLE]
alloc(hp,8)
registersymbol(hp)
{$lua}
function replaceString(string_in,string_out,ignore_length)
if (not ignore_length) then
if (not(string_in and string_out and #string_in >= #string_out)) then
return print("Not recommended to override shorter string with a longer string");
end
end
local bytes_in = {};
local bytes_out = {};
for i=1,(#string_in >= #string_out and #string_in or #string_out) do
if (i <= #string_in) then
table.insert(bytes_in,string.format("%x", tonumber(string.byte(string.sub(string_in,i,i)))));
end
if (i <= #string_out) then
table.insert(bytes_out,tonumber(string.byte(string.sub(string_out,i,i))));
end
end
local object = AOBScan(table.concat(bytes_in," "));
if object then
for entry = 0, object.Count -1 do
writeBytes(object.getString(entry), unpack(bytes_out));
end
object.destroy();
print("Replaced some ...")
return true
end
print("Finished ")
return false
end
function Butt(sender)
replaceString("OLDword","NEWword",true)
end
hkey=createHotkey("Butt",VK_Z)
[DISABLE]
{$lua}
hkey.destroy("Butt",VK_Z)
|
Last edited by Devon999 on Sun Jun 05, 2022 3:52 pm; edited 3 times in total |
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1055 Location: 0x90
|
Posted: Wed May 25, 2022 3:09 pm Post subject: |
|
|
What do you mean use an ASM variable? You mention HP variable in the addresslist. The addresslist doesn't contain variables, but records that contain values of a specific data type, or script.
|
|
Back to top |
|
|
Devon999 Newbie cheater Reputation: 0
Joined: 03 May 2022 Posts: 23
|
Posted: Wed May 25, 2022 3:12 pm Post subject: |
|
|
LeFiXER wrote: | What do you mean use an ASM variable? You mention HP variable in the addresslist. The addresslist doesn't contain variables, but records that contain values of a specific data type, or script. |
So like if I set a var named hp in AA script I can use it by typing [hp] but when the line I need to insert [hp] into is Lua how to I insert it?
This attempt for example did not work...
replaceString("RandomNameLOL",{$asm}[hp]{$lua},true)
How do I use [hp] in that lua line to change "RandomNameLOL" to the string in the [hp] var?
(Sorry if its confusing but I struggle with English and learning sometimes due to a learning disability)
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1055 Location: 0x90
|
Posted: Wed May 25, 2022 3:59 pm Post subject: |
|
|
Well, if you registered the symbol you can just read/write the value of the symbol directly:
Code: |
writeString('symbol_of_address', 'text_to_write', true/false) -- true = widechar, false = ansichar
|
This is assuming in the AA script in your table, hp has a registered symbol with the name hp.
Edit: Fixing a mistake
Last edited by LeFiXER on Thu May 26, 2022 4:11 am; edited 1 time in total |
|
Back to top |
|
|
Devon999 Newbie cheater Reputation: 0
Joined: 03 May 2022 Posts: 23
|
Posted: Wed May 25, 2022 4:58 pm Post subject: |
|
|
LeFiXER wrote: | Well, if you registered the symbol you can just read/write the value of the symbol directly:
Code: |
writeString('RandonNameLOL', 'hp', true/false) -- true = widechar, false = ansichar
|
This is assuming in the AA script in your table, hp has a registered symbol with the name hp. |
As of right now it's not working. It takes the hp as text and literally replaces with the letters hp instead of the value of the symbol. I think I need different markings on the 'hp' than on the 'RandomNameLOL' don't I? The RandomNameLOL is text to replace, and the hp is a symbol I gave a value in my addresslist after making an address with the address: hp
The hp is also allocated and registered as seen in the full version of the code I post earlier.
Trying some things in the meantime and if I get it working I'll reply again but so far I need more help on it. And are you sure it can be writeString instead of replaceString?
EDIT: I guess maybe I'm asking the wrong way? I started a different thread with a different approach maybe it will work easier so I guess unless somebody knows easy solution to this thread, just disregard this one for now idk +shrug+
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4289
|
Posted: Wed May 25, 2022 9:49 pm Post subject: |
|
|
Something like this?
Code: | ...
function Butt(sender)
local newword = readString('hp', 8)
if newword then
replaceString("OLDword", newword, true)
end
end
... |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
|
|
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
|
|