|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1257
|
Posted: Thu Mar 21, 2019 2:10 pm Post subject: [solved]Format text as "Aob". |
|
|
It's not clear when you need it.
Sometimes practical jobs, with one click,
You may want to format the text as Aob.
Here's the code, down there.
For this code: @Corroder +1, befitting.
Code: | f = createForm(true)
f.Position = poDesktopCenter
f.Width = 398
f.Height = 130
e1 = createEdit(f)
e1.Height = 23
e1.Left = 7
e1.Top = 49
e1.Width = 384
e2 = createEdit(f)
e2.Height = 23
e2.Left = 7
e2.Top = 84
e2.Width = 384
b1 = createButton(f)
b1.Left = 56
b1.Top = 10
b1.caption = "Format"
b2 = createButton(f)
b2.Left = 223
b2.Top = 10
b2.caption = "Reset"
--===================================--
-- @Corroder Code.. Thanks Dude --
--===================================--
function num2hex(num)
local hexstr = '0123456789ABCDEF'
local s = ' ' --The gap between the quote solves the problem
while num > 0 do
local mod = math.fmod(num, 16)
s = string.sub(hexstr, mod+1, mod+1) .. s
num = math.floor(num / 16)
end
if s == '' then s = '0' end
return s
end
function str2hex(str)
local hex = ''
while #str > 0 do
local hb = num2hex(string.byte(str, 1, 1))
if #hb < 2 then hb = '1' .. hb end
hex = hex .. hb
str = string.sub(str, 2)
end
return hex
end;
--===================================--
b1.OnClick = function()
a = e1.Text
b = str2hex(a)
e2.Text=(b)
end
b2.OnClick = function()
e1.Text=""
e2.Text=""
end |
Example Text: e_powerup_avatar_speed
Output: 65 5F 70 6F 77 65 72 75 70 5F 61 76 61 74 61 72 5F 73 70 65 65 64
Enjoy it!
_________________
Last edited by AylinCE on Sat Mar 23, 2019 2:19 pm; edited 1 time in total |
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Fri Mar 22, 2019 2:05 am Post subject: |
|
|
Since CEEdit contains is 'Text', of course, your function only accepts number when an input on CEEdit field with convert input text number to real number using tonumber() command.
String '100' will give result number 100 with tonumber('100'), but will give result as nil if you input 'ab100', etc.
But, here as mentioned by @TheyCallMeTim:
Code: | local bt = stringToByteTable('test')
for i, v in ipairs(bt) do
print(i - 1, string.format('%02X', v))
end
result : [[
0 74
1 65
2 73
3 74
]] -- you need format result to '74 65 73 74'
|
other :
Code: | function num2hex(num)
local hexstr = '0123456789abcdef'
local s = ''
while num > 0 do
local mod = math.fmod(num, 16)
s = string.sub(hexstr, mod+1, mod+1) .. s
num = math.floor(num / 16)
end
if s == '' then s = '0' end
return s
end
function str2hex(str)
local hex = ''
while #str > 0 do
local hb = num2hex(string.byte(str, 1, 1))
if #hb < 2 then hb = '0' .. hb end
hex = hex .. hb
str = string.sub(str, 2)
end
return hex
end;
a = '100 Cheat Engine'
b = str2hex(a)
print(b)
-- result : 31303020436865617420456e67696e65
-- you need format it as output you wish |
Btw, I have other version sor string to AOB in lua script.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1257
|
Posted: Fri Mar 22, 2019 3:34 am Post subject: |
|
|
@TheyCallMeTim, Your link has a very rich code page.
Thanks dude.
@Corroder, Still possible in CE. I think @DarkByte knows the answer.
In the game I'm interested in, there are 65 thousand codes as follows.
String: Code: | e_powerup_avatar_speed_7d |
Aob: Code: | 65 5F 70 6F 77 65 72 75 70 5F 61 76 61 74 61 72 5F 73 70 65 65 64 5F 37 64 |
Currently, only 43'll format.
Coding at CE every time will be exhausting.
I'll have a little more research.
_________________
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25291 Location: The netherlands
|
Posted: Fri Mar 22, 2019 4:17 am Post subject: |
|
|
use string.byte to convert strings to bytes
http://lua-users.org/wiki/StringLibraryTutorial
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1257
|
Posted: Fri Mar 22, 2019 5:46 am Post subject: |
|
|
@Corroder, big thanks dude..
I'm sorry I noticed late.
But the code worked great with intermediate spaces.
code: e_powerup_avatar_speed
AOB output: 65 5F 70 6F 77 65 72 75 70 5F 61 76 61 74 61 72 5F 73 70 65 65 64
Code: | f = createForm(true)
f.Position = poDesktopCenter
f.Width = 398
f.Height = 130
e1 = createEdit(f)
e1.Height = 23
e1.Left = 7
e1.Top = 49
e1.Width = 384
e2 = createEdit(f)
e2.Height = 23
e2.Left = 7
e2.Top = 84
e2.Width = 384
b1 = createButton(f)
b1.Left = 56
b1.Top = 10
b1.caption = "Format"
b2 = createButton(f)
b2.Left = 223
b2.Top = 10
b2.caption = "Reset"
--===================================--
-- @Corroder Code.. Thanks Dude --
--===================================--
function num2hex(num)
local hexstr = '0123456789ABCDEF'
local s = ' ' --The gap between the quote solves the problem
while num > 0 do
local mod = math.fmod(num, 16)
s = string.sub(hexstr, mod+1, mod+1) .. s
num = math.floor(num / 16)
end
if s == '' then s = '0' end
return s
end
function str2hex(str)
local hex = ''
while #str > 0 do
local hb = num2hex(string.byte(str, 1, 1))
if #hb < 2 then hb = '1' .. hb end
hex = hex .. hb
str = string.sub(str, 2)
end
return hex
end;
--===================================--
b1.OnClick = function()
a = e1.Text
b = str2hex(a)
e2.Text=(b)
end
b2.OnClick = function()
e1.Text=""
e2.Text=""
end
|
_________________
|
|
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
|
|