Difference between revisions of "Lua:readSmallInteger"

From Cheat Engine
Jump to navigation Jump to search
m (Syntax Highlighting.)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
'''function''' readSmallInteger(''Address'') ''':''' integer
+
{{CodeBox|'''function''' readSmallInteger(''Address'') ''':''' Integer}}
  
Reads a WORD (2 bytes) at the given address and interprets them as an integer
+
Reads a 16-bit integer (small integer) from the specified address in the currently opened (target) process.
  
 
===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 11: Line 11:
 
|-
 
|-
 
|Address
 
|Address
|[[CEAddressString]] or Integer
+
|Integer or [[CEAddressString]]
|The address to read
+
|The address in the target process to read from.
 +
|-
 +
|Flag
 +
|[[Boolean]]
 +
|If 'true', CE will interpret value as signed. If false or missing, CE will interpret value as unsigned.
 
|}
 
|}
  
 +
===Returns===
 +
Integer — The 16-bit integer value read from the specified address.
 +
 +
===Examples===
 +
<syntaxhighlight lang="lua" line>
 +
-- Read a 16-bit integer from address 0x123456
 +
local value = readSmallInteger(0x123456)
 +
print("Value:", value)
 +
 +
-- Read from a CEAddressString
 +
local value2 = readSmallInteger("game.exe+1234")
 +
print("Value:", value2)
 +
</syntaxhighlight>
  
 
{{LuaSeeAlso}}
 
{{LuaSeeAlso}}
  
=== Related Functions ===
 
 
{{ReadWriteMemory}}
 
{{ReadWriteMemory}}

Latest revision as of 15:27, 25 June 2026

<> Lua API Reference

function readSmallInteger(Address) : Integer

Reads a 16-bit integer (small integer) from the specified address in the currently opened (target) process.

Function Parameters[edit]

Parameter Type Description
Address Integer or CEAddressString The address in the target process to read from.
Flag Boolean If 'true', CE will interpret value as signed. If false or missing, CE will interpret value as unsigned.

Returns[edit]

Integer — The 16-bit integer value read from the specified address.

Examples[edit]

1 -- Read a 16-bit integer from address 0x123456
2 local value = readSmallInteger(0x123456)
3 print("Value:", value)
4 
5 -- Read from a CEAddressString
6 local value2 = readSmallInteger("game.exe+1234")
7 print("Value:", value2)

Main Pages

Core Lua documentation entry points

Lua
Script Engine