Difference between revisions of "Lua:readBytesLocal"

From Cheat Engine
Jump to navigation Jump to search
(Dilber)
m (Added CodeBox Template.)
 
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
'''function''' readBytes(''Address'', ''Bytecount'', ''ReturnAsTable'' )
+
[[Category:Lua]]
 +
{{CodeBox|'''function''' readBytesLocal(''Address'', ''ByteCount'', [''ReturnAsTable''])}}
  
Returns the bytes at the given address
+
Reads bytes from the specified address in Cheat Engine's own process memory (not the target process). 
 +
Returns the bytes as multiple return values or as a table if ''ReturnAsTable'' is true.
  
Note: The bytes read are from the Cheat Engine process instead of the targeted process
+
===Function Parameters===
 +
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Parameter
 +
!align="left"|Type
 +
!style="width: 80%;background-color:white;" align="left"|Description
 +
|-
 +
|Address
 +
|Integer or [[CEAddressString]]
 +
|The address in Cheat Engine's memory to read from.
 +
|-
 +
|ByteCount
 +
|Integer
 +
|The number of bytes to read.
 +
|-
 +
|ReturnAsTable
 +
|Boolean (optional)
 +
|If true, returns a table of bytes. If false or omitted, returns each byte as a separate return value.
 +
|}
  
I don't think you can do it directly from a CSV. But, if you imorpt the whole CSV and save it as an HTML table, you can use that table as a Spry Data Source. Here are the steps:1. Import CSV into n HTML table following this tutorial2. Give the table an ID, i.e. id= data 3. Save the file. i.e data.html4. Create a new HTML file and go to Insert->Spry->Spry Data Set5. A three step wizard will launch that will help you with the rest.6. On the last step of the process make sure to click the  Set Up  button, which will help you pick the columns :)I know it's not as simple, but you may like the result!
+
===Examples===
 +
<pre>
 +
-- Read 4 bytes and get them as separate values
 +
local b1, b2, b3, b4 = readBytesLocal(0x123456, 4)
 +
print(b1, b2, b3, b4)
  
== See also ==
+
-- Read 4 bytes and get them as a table
* [[readBytes]]
+
local bytes = readBytesLocal(0x123456, 4, true)
* [[Lua]]
+
for i, v in ipairs(bytes) do
 +
  print("Byte " .. i .. ": " .. v)
 +
end
 +
</pre>
 +
 
 +
{{LuaSeeAlso}}
 +
 
 +
=== Related Functions ===
 +
{{ReadWriteMemory}}

Latest revision as of 23:02, 4 December 2025

<> Function

function readBytesLocal(Address, ByteCount, [ReturnAsTable])

Reads bytes from the specified address in Cheat Engine's own process memory (not the target process). Returns the bytes as multiple return values or as a table if ReturnAsTable is true.

Function Parameters[edit]

Parameter Type Description
Address Integer or CEAddressString The address in Cheat Engine's memory to read from.
ByteCount Integer The number of bytes to read.
ReturnAsTable Boolean (optional) If true, returns a table of bytes. If false or omitted, returns each byte as a separate return value.

Examples[edit]

-- Read 4 bytes and get them as separate values
local b1, b2, b3, b4 = readBytesLocal(0x123456, 4)
print(b1, b2, b3, b4)

-- Read 4 bytes and get them as a table
local bytes = readBytesLocal(0x123456, 4, true)
for i, v in ipairs(bytes) do
  print("Byte " .. i .. ": " .. v)
end

See also[edit]

Lua
Script Engine

Related Functions[edit]

Read Functions
readBytes
readSmallInteger
readInteger
readQword
readPointer
readFloat
readDouble
readString
Read Functions (Local Process)
readBytesLocal
readIntegerLocal
readQwordLocal
readPointerLocal
readFloatLocal
readDoubleLocal
readStringLocal
Write Functions
writeBytes
writeSmallInteger
writeInteger
writeQword
writeFloat
writeDouble
writeString
Write Functions (Local Process)
writeBytesLocal
writeIntegerLocal
writeQwordLocal
writeFloatLocal
writeDoubleLocal
writeStringLocal
Byte Table Conversions (Value → Byte Table)
wordToByteTable
dwordToByteTable
qwordToByteTable
floatToByteTable
doubleToByteTable
stringToByteTable
wideStringToByteTable
Byte Table Conversions (Byte Table → Value)
byteTableToWord
byteTableToDword
byteTableToQword
byteTableToFloat
byteTableToDouble
byteTableToString
byteTableToWideString