 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Outlivinglife Newbie cheater
Reputation: 0
Joined: 21 Aug 2018 Posts: 19
|
Posted: Fri May 01, 2020 12:10 pm Post subject: Array of Bytes - Dropdown Options |
|
|
Let's say a character's name is: Arnold and it's stored at memory address 00839C60. And let's say the game uses 60 (Hex) = A ... 79 (Hex) = Z, 80 (Hex) = a ... 99 (Hex) = z.
To show these lines (for editting) in cheat engine, I have it showing as such:
Code: | 00839C60 60
00839C61 91
00839C62 8D
00839C63 8E
00839C64 8B
00839C65 83 |
Using Dropdown options, I can set it to show those hex values as letters as such:
Code: | 00839C60 A
00839C61 r
00839C62 n
00839C63 o
00839C64 l
00839C65 d |
If I make a field with type 'Array of Bytes', starting at address 00839C60 and continuing for a length of 6, I can get it to show up as such:
Code: | 00839C60 60 91 8D 8E 8B 83 |
Is there anyway to use Dropdown options to make it show up as such:
Code: | 00839C60 A r n o l d |
I feel like there is, but I'm just overlooking it. Thanks!
|
|
Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri May 01, 2020 6:37 pm Post subject: |
|
|
Copy paste this to main CE form (right click empty space in bottom part of CE and choose paste).
Code: | <?xml version="1.0" encoding="utf-8"?>
<CheatTable>
<CheatEntries>
<CheatEntry>
<Description>"Special text (minus31)"</Description>
<LastState/>
<VariableType>Auto Assembler Script</VariableType>
<AssemblerScript>{$Lua}
if syntaxcheck then return end
[ENABLE]
-- TMemoryRecord.OnGetDisplayValue
local function OnGetDisplayValue_Minus31Text(memoryrecord,valuestring)
local decodedText = ''
local base=memoryrecord.ShowAsHex and 16 or 10 -- should work for decimalAOB and hexAOB
for c in valuestring:gmatch('%x+') do -- %x matches 0-9 and a-fA-F
local byte = tonumber(c,base)
if (byte-31)<=0 then break end
decodedText=decodedText..string.char(byte-31) -- 0x60 -> 0x41
end
return true,decodedText
end
for i=0,memrec.Count-1 do
if memrec[i].Type==vtByteArray then -- only array of bytes
memrec[i].OnGetDisplayValue = OnGetDisplayValue_Minus31Text
end
end
[DISABLE]
for i=0,memrec.Count-1 do
if memrec[i].Type==vtByteArray then -- only array of bytes
memrec[i].OnGetDisplayValue = nil
end
end
</AssemblerScript>
</CheatEntry>
</CheatEntries>
</CheatTable>
|
Then move your memoryrecord entry (type: array of byte) inside just pasted memoryrecord/script.
Activate "Special text (minus31)" script.
I already have script which allows editing. I can share if you want.
_________________
|
|
Back to top |
|
 |
Outlivinglife Newbie cheater
Reputation: 0
Joined: 21 Aug 2018 Posts: 19
|
Posted: Sun May 03, 2020 5:48 am Post subject: |
|
|
Oh, boy. That looks like a confusing piece of code lol. Thanks! I'll have to implement it next time I'm on that game .
|
|
Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Mon May 04, 2020 1:18 pm Post subject: |
|
|
Here, more confusing code. You can change the text after double clicking value in address list:
(remember that games do not like changing text length).
PS: I assumed space char is 0x3F and string termination is 0x00
Code: | <?xml version="1.0" encoding="utf-8"?>
<CheatTable>
<CheatEntries>
<CheatEntry>
<Description>"Special text (minus31)"</Description>
<LastState/>
<VariableType>Auto Assembler Script</VariableType>
<AssemblerScript>{$Lua}
if syntaxcheck then return end
-- OldOnValueChange_Minus31Text keeps other TAddresslist.OnValueChange
-- tableWithMemrecs_Minus31Text has memoryrecords which OnValueChange should handle, also keeps decoded text
[ENABLE]
-- TMemoryRecord.OnGetDisplayValue
local function OnGetDisplayValue_Minus31Text(memoryrecord,valuestring)
local decodedText = ''
local base=memoryrecord.ShowAsHex and 16 or 10 -- should work for decimalAOB and hexAOB
for c in valuestring:gmatch('%x+') do -- %x matches 0-9 and a-fA-F
local byte = tonumber(c,base)
if (byte-31)<=0 then break end
decodedText=decodedText..string.char(byte-31) -- 0x60 -> 0x41
end
tableWithMemrecs_Minus31Text[userDataToInteger(memoryrecord)] = decodedText
return true,decodedText
end
-- TAddresslist.OnValueChange
local function OnValueChange_Minus31Text(addresslist,memoryrecord)
-- Minus31Text memrec? if decodedText=nil then this is not Minus31Text memrec
local decodedText = tableWithMemrecs_Minus31Text[userDataToInteger(memoryrecord)]
if decodedText~=nil then
local base=memoryrecord.ShowAsHex and '%x ' or '%d '
local newStr = inputQuery('Change Value (Minus31Text)', 'what value to change this to?', decodedText)
if newStr~=nil and newStr~='' then
local aob = ''
newStr:gsub('.', function (c) aob=aob..string.format(base,string.byte(c)+31) end)
memoryrecord.Value = aob..'0' -- zero terminator
end
return true
else
-- deal with other OnValueChange (if exists)
if Old_OnValueChange_Minus31Text~=nil then return Old_OnValueChange_Minus31Text(addresslist,memoryrecord) end
end
return false
end
Old_OnValueChange_Minus31Text = AddressList.OnValueChange
AddressList.OnValueChange = OnValueChange_Minus31Text
tableWithMemrecs_Minus31Text = {}
for i=0,memrec.Count-1 do
if memrec[i].Type==vtByteArray then -- only array of bytes
memrec[i].OnGetDisplayValue = OnGetDisplayValue_Minus31Text
end
end
[DISABLE]
AddressList.OnValueChange=Old_OnValueChange_Minus31Text
for i=0,memrec.Count-1 do
if memrec[i].Type==vtByteArray then -- only array of bytes
memrec[i].OnGetDisplayValue = nil
end
end
tableWithMemrecs_Minus31Text = {}
</AssemblerScript>
</CheatEntry>
</CheatEntries>
</CheatTable>
|
PSS: @DarkByte, too bad OnValueChange is only for AddressList...
_________________
|
|
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
|
|