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 


How can I convert this string to work with math?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Autem
Expert Cheater
Reputation: 1

Joined: 30 Jan 2023
Posts: 156

PostPosted: Thu Apr 17, 2025 4:01 pm    Post subject: How can I convert this string to work with math? Reply with quote

How would I change a variable type from string into hex without actually changing the content? For example I have a variable that is considered a string but contains 2F58B0, so I just want to make it so that 2F58B0 can be used like a number and have math performed on it. I've tried some format/changing methods such as ("%02X"),("%8X"),stringToByteTable,readBytes,etc... in the missing 4th line below but can't make it so the result stays the same actual value while also being interpreted as a number. In some cases, I was getting a printed result of 1,INF instead of the desired result.

Unlike yesterday's somewhat similar situation I was in, this script will need the game module and its offset once I add on to it, which is why I want to start with the module included and go through the trouble of converting its offset to use with math.

Code:

local stripped = getAddressList().getMemoryRecordByDescription("").Address --grab the base pointer of the memrec that has NO NAME
local stripped = string.gsub(stripped, '%s+', '') --remove white space (maybe not necessary?)
local stripped = string.gsub(stripped, 'Game_x64.exe%+', '') --strip away the game.exe+, leaving only the module offset behind
?? missing line 4 step to change remaining offset from string so math can be performed on it ??
print(stripped+0xA0)
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4691

PostPosted: Thu Apr 17, 2025 4:26 pm    Post subject: Reply with quote

Use `getAddress` to convert some arbitrary string into an integer. (if it's passed an integer, it will return that integer)
Code:
local addr = getAddress(AddressList["description"].Address)

print(getNameFromAddress(addr + 0xA0))

_________________
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
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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