 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
animereunion Cheater
Reputation: 0
Joined: 06 May 2012 Posts: 26
|
Posted: Sat Jul 18, 2020 8:18 am Post subject: readString address |
|
|
Hi, I'm new in scripting but I'm mostly can get the code by reading its value and compare to existing database from someone else script.
This is Dark Soul 3 lua script that initiate the script if certain value are met
Code: | if readInteger"[[[[BaseB]+40]+28]+420]+C8" == 152034000 then
writeBytes("standflag", 1)
writeBytes("standflag+1", 1)
end |
So I'm using this table and its value for reference:
Just in case if screencap got erase:
▪ Last Animation P-> 7FF4AF4DA938 4 Bytes 452034000
▪ Current Animation Integer P->7FF4AF4D98E8 4 Bytes 00740041
▪ Current Animation Name P-> 7FF4AF4D98E8 Unicode String[20] AttackBothLight1
So what I'm try to do is, instead use readInteger to read it as decimal value, I want to use "Current animation name" as trigger. The best result I could find in cheatengine Wiki is:
Code: | readString"[[[[BaseB]+80]+XA]+28]+898, 20, false" == AttackBothLight1 |
Well, it didn't work. The address is correct because when I convert it to readInteger, it does trigger, but it have limitation. So if anyone can help me with this, thank you.
Description: |
|
Filesize: |
3.36 KB |
Viewed: |
2811 Time(s) |

|
Last edited by animereunion on Sat Jul 18, 2020 3:25 pm; edited 1 time in total |
|
Back to top |
|
 |
panraven Grandmaster Cheater
Reputation: 62
Joined: 01 Oct 2008 Posts: 958
|
Posted: Sat Jul 18, 2020 9:47 am Post subject: |
|
|
This form
Code: | readInteger"[[[[BaseB]+40]+28]+420]+C8" |
is a lua syntax sugar/short-hand for SINGLE PARAMETER Function call ONLY when the single parameter is a LITERAL String or LITERAL Table.
When more than one parameter or input parameter is not literal string or literal tale, the function call bracket'(' ... ')' must be used.
So should be
Code: |
readString ( "[[[[BaseB]+80]+XA]+28]+898", 20, false ) == "AttackBothLight1"
|
Note, Unicode is WideChar (in celua.txt doc), may be the 'false' should be 'true'
_________________
- Retarded. |
|
Back to top |
|
 |
animereunion Cheater
Reputation: 0
Joined: 06 May 2012 Posts: 26
|
Posted: Sat Jul 18, 2020 10:24 am Post subject: |
|
|
Thank you.
But if I want to use readByte, does this format correct?
Quote: | function readBytes(Address, Bytecount, ReturnAsTable ) : (byte, ...) - table
Returns the bytes at the given address |
Code: |
readBytes( "[[[[BaseB]+80]+XA]+28]+898", 42, true ) == 41 00 74 00 74 00 61 00 63 00 6B 00 52 00 69 00 67 00 68 00 74 00 48 00 65 00 61 00 76 00 79 00 31 00 45 00 6E 00 64 00 00 00 |
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4697
|
Posted: Sat Jul 18, 2020 10:52 am Post subject: |
|
|
No. The third parameter specifies if it should return bytes as a table. That thing on the right of == isn't a table- it's a syntax error.
Code: | function array_eq(t1, t2)
if #t1 ~= #t2 then return false end
for i,v in ipairs(t1) do
if t2[i] ~= v then return false end
end
return true
end
local mytable = {0x41, 0x00, 0x74, 0x00, 0x74, 0x00,
0x61, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x52, 0x00, 0x69,
0x00, 0x67, 0x00, 0x68, 0x00, 0x74, 0x00, 0x48, 0x00,
0x65, 0x00, 0x61, 0x00, 0x76, 0x00, 0x79, 0x00, 0x31,
0x00, 0x45, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x00, 0x00}
local othertable = readBytes("[[[[BaseB]+80]+XA]+28]+898", 42, true)
array_eq(mytable, othertable)
|
Also, you have "XA" for an offset. It's probably not what you want.
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Last edited by ParkourPenguin on Sat Jul 18, 2020 2:47 pm; edited 1 time in total |
|
Back to top |
|
 |
animereunion Cheater
Reputation: 0
Joined: 06 May 2012 Posts: 26
|
Posted: Sat Jul 18, 2020 11:36 am Post subject: |
|
|
Thank you for reply
does "!=" not in lua script, I got error when I try to apply that. I assume is from python script which "not equal to", so I assume I can correct it with "~=", right?
ParkourPenguin wrote: | No. The third parameter specifies if it should return bytes as a table. That thing on the right of == isn't a table- it's a syntax error.. |
What if I turn third parameter to false, am I translate it to decimal value?
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4697
|
Posted: Sat Jul 18, 2020 2:49 pm Post subject: |
|
|
My bad, Lua is a weird one in that it uses ~= instead of !=. Edited the previous post.
If you pass false (or don't pass anything), it just pushes numbers onto the Lua stack. This lets you do stuff like this:
Code: | local b1, b2, b3, b4 = readBytes(address, 4) |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
animereunion Cheater
Reputation: 0
Joined: 06 May 2012 Posts: 26
|
Posted: Sat Jul 18, 2020 4:32 pm Post subject: |
|
|
Thank you for reply.
ParkourPenguin wrote: | Code: | local b1, b2, b3, b4 = readBytes(address, 4) |
|
So if I gonna take readBytes function to this code:
Code: | if readInteger"[[[[BaseB]+40]+28]+420]+C8" == 152034000 then
writeBytes("standflag", 1)
writeBytes("standflag+1", 1)
end |
I want to replace
Code: | readInteger"[[[[BaseB]+40]+28]+420]+C8" == 152034000 |
into readBytes() function, so.... how can I apply it? Formula I try to work it out is,
"if the address value is equal to my input, it will trigger "standflag""
in this case AttackBothLight1 is my string input, an integer code for AttackBothLight1 is 152034000.
So with given code you give me... should I wrote it like this?
Code: | readBytes( "[[[[BaseC]+80]+1f90]+28]+898", 42) == local 73, 0, 100, 0, 108, 0, 101, 0, 0, 0, 111, 0, 112, 0, 70, 0, 114, 0, 111, 0, 110, 0, 116, 0, 0, 0, 104, 0, 116, 0, 49, 0, 0, 0, 0, 0, 100, 0, 0, 0, 116, 0 |
Sorry, I know the basic of coding based how it construct but I couldn't not make it for my self. If the code too long let me input it. I just wanted to know wnat I should put after == in readBytes() function.
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4697
|
Posted: Sat Jul 18, 2020 8:03 pm Post subject: |
|
|
No, you shouldn't. Look at the first code I posted- that is how you check if the result of readBytes is equal to something.
You should learn Lua before trying to write Lua code. Search for "Lua tutorial"; there's plenty of resources out there.
Also, you can change this:
Code: | writeBytes("standflag", 1)
writeBytes("standflag+1", 1) | To this:
Code: | writeBytes("standflag", 1, 1) |
_________________
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
|
|