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 


dec->hex as offset

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Tue Jul 13, 2021 12:29 am    Post subject: dec->hex as offset Reply with quote

I can't use dec->hex as offset
In game decimal offset is stored in 0xBA6774
Code:
decOffset = readBytes(0xBA6774);
hexOffset = decOffset * 40;
print(string.format('%x%',hexOffset); --Prints hexadecimal value but can't be used in offset

I trying to make pointer with this in lua
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 199

Joined: 25 Jan 2006
Posts: 8518
Location: 127.0.0.1

PostPosted: Tue Jul 13, 2021 1:59 am    Post subject: Reply with quote

This isn't even valid Lua code to begin with. If you are going to ask for help, it's best to actually paste the working code you've tried than trying to piece together things without testing them and saying 'i tried this' when it's obvious you didn't.

If you want to format a decimal number as a hex format, you can do:
Code:

local hexOffset = 12345;
local hexString = string.format('0x%X', hexOffset);
print(hexString);


You can remove the 0x at the start of the format as needed to keep the string in hex format but without the prefix.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Tue Jul 13, 2021 2:26 am    Post subject: Reply with quote

Code:
WPDec = readBytes(0xBA6774);
WPHex = WPDec * 40;

I used this to make pointer to waypoint struct(0xBA6774 is used to get decimal offset to waypoint,then i multiply this value to get decimal value, and then converted it to hexadecimal)
Example: We have waypoint struct that allocated in 0xBA9000(this address is changing every time we restart the game),but we didn't have hexadecimal offset so then we reading bytes in 0xBA6774 and it gives us 44 then we multiply this to 40 and it gives 1760 in decimal then converting it we getting hexadecimal offset
In Cheat Engine Lua i use this:
Code:
wpptr = 0xBA86F0; --Base address for waypoint struct
waypoint = {
Color = ("wpptr + WPHex + 0");
XPos = ("wpptr + WPHex + 8");
YPos = ("wpptr + WPHex + C");
ZPos = ("wpptr + WPHex + 10");
Size = ("wpptr + WPHex + 14");
}
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 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