Difference between revisions of "Lua:writeString"

From Cheat Engine
Jump to navigation Jump to search
(Created page with ''''function''' writeString(''Address'', ''Text'') Writes the given text to the given address. This does not write a 0-terminator at the end. You need to use writeBytes yours…')
 
m (Syntax Highlighting.)
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''function''' writeString(''Address'', ''Text'')
+
[[Category:Lua]]
 +
{{CodeBox|'''function''' writeString(''Address'', ''Text'', [''WideChar'']) ''':''' Boolean}}
  
Writes the given text to the given address. This does not write a 0-terminator at the end. You need to use [[writeBytes]] yourself if you need one
+
Writes a string to the specified address in the currently opened (target) process.
 +
Set ''WideChar'' to true to write the string as widechar (UTF-16/Unicode). 
 +
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 10: Line 13:
 
|-
 
|-
 
|Address
 
|Address
|[[CEAddressString]] or Integer
+
|Integer or [[CEAddressString]]
|The address of the target process to write to
+
|The address in the target process to write to.
 
|-
 
|-
 
|Text
 
|Text
 
|String
 
|String
|The text to write to the process
+
|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===
 +
Boolean — true if the write was successful, false otherwise.
 +
 +
===Examples===
 +
<syntaxhighlight lang="lua" line>
 +
-- Write an ASCII string to address 0x123456
 +
local success = writeString(0x123456, "Hello, world!")
 +
print("Write successful:", success)
 +
 +
-- Write a widechar (Unicode) string to a CEAddressString
 +
writeString("game.exe+1234", "Unicode Text", true)
 +
</syntaxhighlight>
 +
 +
{{LuaSeeAlso}}
 +
 +
{{RelatedStrings}}
  
== See also ==
+
{{ReadWriteMemory}}
* [[readString]]
 
* [[writeBytes]]
 
* [[writeInteger]]
 
* [[writeFloat]]
 
* [[writeDouble]]
 
* [[Lua]]
 

Latest revision as of 15:43, 25 June 2026

<> Lua API Reference

function writeString(Address, Text, [WideChar]) : Boolean

Writes a string to the specified address in the currently opened (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 the target process to write to.
Text 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]

1 -- Write an ASCII string to address 0x123456
2 local success = writeString(0x123456, "Hello, world!")
3 print("Write successful:", success)
4 
5 -- Write a widechar (Unicode) string to a CEAddressString
6 writeString("game.exe+1234", "Unicode Text", true)

Main Pages

Core Lua documentation entry points

Lua
Script Engine

String Related Lua Functions

Encoding conversion and localized text helpers