|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Fri Jul 30, 2021 8:48 am Post subject: Hex,dec calculator |
|
|
Code: | function calcHex(value)
hexOffset = string.format('0x%X',value);
print(hexOffset)
end
function calcDec(value)
decOffset = string.format('%d',value)
print(decOffset)
end |
I can't use function calcDec like this 'calcDec(BC)'
And help me with the form please(i'm trying to make dec,hex calculator window)
Description: |
|
Download |
Filename: |
Hex Calculator.LUA |
Filesize: |
391 Bytes |
Downloaded: |
138 Time(s) |
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1053 Location: 0x90
|
Posted: Fri Jul 30, 2021 12:34 pm Post subject: |
|
|
It's not necessary to have a calcDec function use tonumber([hex value])
example:
Code: |
local x = 0xA
print(tonumber(x))
--Should print 10 to console
|
But, if you insist on using your own function. The error is that you failed to prepend "0x" to the value passed to the calcDec function like so:
Fully working functions here and example of usage.
Code: |
function calcHex(value)
hexOffset = string.format('0x%X',value);
print(hexOffset)
return hexOffset
end
function calcDec(value)
decOffset = string.format('%d', value);
print(decOffset)
return decOffset
end
function calcHexAddress(addr,value)
hexAddr = (string.format("%X", addr + value))
print(hexAddr)
return hexAddr
end
function calcDecAddress(addr,value)
decAddr = string.format('%d', addr + value)
print(decAddr)
return decAddr
end
calcHex(10) -- A
calcDec(0xFF) -- 255
calcHexAddress(0x400000,0xBEEF) -- 40BEEF
calcDecAddress(0x400000,0xBEEF) -- 4243183
|
|
|
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
|
|