Difference between revisions of "Lua:writeStringLocal"

From Cheat Engine
Jump to navigation Jump to search
m
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
'''function''' writeStringLocal(''Address'', ''Text'', ''WideChar'' OPTIONAL)
+
'''function''' writeStringLocal(''Address'', ''String'', [''WideChar'']) ''':''' Boolean
  
Writes the given text to the given address, in Cheat Engine's memory. This does not write a 0-terminator at the end. You need to use [[writeBytesLocal]] yourself if you need one. Set WideChar to true if it is encoded using a widechar formatting.
+
Writes a string to the specified address in Cheat Engine's own process memory (not the target process).
 
+
Set ''WideChar'' to true to write the string as widechar (UTF-16/Unicode).
Note: The value written will be in the Cheat Engine process instead of the targeted process.
+
Returns true on success.
  
 
===Function Parameters===
 
===Function Parameters===
{|width="85%" cellpadding="10%" cellpadding="5%" cellspacing="0" border="0"
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 
!align="left"|Parameter
 
!align="left"|Parameter
 
!align="left"|Type
 
!align="left"|Type
Line 13: Line 13:
 
|-
 
|-
 
|Address
 
|Address
|[[CEAddressString]] or Integer
+
|Integer or [[CEAddressString]]
|The address in Cheat Engine's memory to write to
+
|The address in Cheat Engine's memory to write to.
 
|-
 
|-
|Text
 
 
|String
 
|String
|The text to write to Cheat Engine's memory
+
|String
 +
|The string to write.
 
|-
 
|-
 
|WideChar
 
|WideChar
|boolean
+
|Boolean (optional)
|Set to true if it is encoded using a widechar formatting
+
|Set to true to write as a widechar (UTF-16/Unicode) string. Default is false (ASCII/ANSI).
 
|}
 
|}
  
 +
===Returns===
 +
Boolean — true if the write was successful, false otherwise.
 +
 +
===Examples===
 +
<pre>
 +
-- Write an ASCII string to address 0x123456 in CE's memory
 +
local success = writeStringLocal(0x123456, "Hello, Cheat Engine!")
 +
print("Write successful:", success)
 +
 +
-- Write a widechar (Unicode) string to a CEAddressString
 +
writeStringLocal("00400000+10", "Unicode Text", true)
 +
</pre>
  
 
{{LuaSeeAlso}}
 
{{LuaSeeAlso}}
Line 32: Line 44:
 
* [[utf8ToAnsi]]
 
* [[utf8ToAnsi]]
 
* [[translate]]
 
* [[translate]]
* [[readBytes]]
+
{{ReadWriteMemory}}
* [[readInteger]]
 
* [[readQword]]
 
* [[readPointer]]
 
* [[readFloat]]
 
* [[readDouble]]
 
* [[readString]]
 
* [[writeBytes]]
 
* [[writeInteger]]
 
* [[writeQword]]
 
* [[writeFloat]]
 
* [[writeDouble]]
 
* [[writeString]]
 
* [[readBytesLocal]]
 
* [[readIntegerLocal]]
 
* [[readQwordLocal]]
 
* [[readPointerLocal]]
 
* [[readFloatLocal]]
 
* [[readDoubleLocal]]
 
* [[readStringLocal]]
 
* [[writeBytesLocal]]
 
* [[writeIntegerLocal]]
 
* [[writeQwordLocal]]
 
* [[writeFloatLocal]]
 
* [[writeDoubleLocal]]
 
* [[wordToByteTable]]
 
* [[dwordToByteTable]]
 
* [[qwordToByteTable]]
 
* [[floatToByteTable]]
 
* [[doubleToByteTable]]
 
* [[stringToByteTable]]
 
* [[wideStringToByteTable]]
 
* [[byteTableToWord]]
 
* [[byteTableToDword]]
 
* [[byteTableToQword]]
 
* [[byteTableToFloat]]
 
* [[byteTableToDouble]]
 
* [[byteTableToString]]
 
* [[byteTableToWideString]]
 

Latest revision as of 17:21, 11 July 2025

function writeStringLocal(Address, String, [WideChar]) : Boolean

Writes a string to the specified address in Cheat Engine's own process memory (not the target process). Set WideChar to true to write the string as widechar (UTF-16/Unicode). Returns true on success.

Function Parameters[edit]

Parameter Type Description
Address Integer or CEAddressString The address in Cheat Engine's memory to write to.
String String The string to write.
WideChar Boolean (optional) Set to true to write as a widechar (UTF-16/Unicode) string. Default is false (ASCII/ANSI).

Returns[edit]

Boolean — true if the write was successful, false otherwise.

Examples[edit]

-- Write an ASCII string to address 0x123456 in CE's memory
local success = writeStringLocal(0x123456, "Hello, Cheat Engine!")
print("Write successful:", success)

-- Write a widechar (Unicode) string to a CEAddressString
writeStringLocal("00400000+10", "Unicode Text", true)

See also[edit]

Related Functions[edit]