Difference between revisions of "Lua:wordToByteTable"
Jump to navigation
Jump to search
m (moved wordToByteTable to Lua:wordToByteTable) |
m |
||
| Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
| − | '''function''' wordToByteTable(''Number'') ''':''' | + | '''function''' wordToByteTable(''Number'') ''':''' Table |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| + | Converts a 16-bit word (integer) to a table of bytes. | ||
===Function Parameters=== | ===Function Parameters=== | ||
| − | {|width="85%" cellpadding="10 | + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" |
!align="left"|Parameter | !align="left"|Parameter | ||
!align="left"|Type | !align="left"|Type | ||
| Line 25: | Line 11: | ||
|- | |- | ||
|Number | |Number | ||
| − | | | + | |Integer |
| − | |The | + | |The 16-bit word to convert. |
|} | |} | ||
| + | ===Returns=== | ||
| + | Table — A table containing the bytes representing the word. | ||
| − | == Examples == | + | ===Examples=== |
| − | + | <pre> | |
| − | + | local bytes = wordToByteTable(0x1234) | |
| − | + | for i, b in ipairs(bytes) do | |
| − | + | print(string.format("Byte %d: %02X", i, b)) | |
| − | + | end | |
| − | + | -- Output: Byte 1: 34, Byte 2: 12 (little-endian order) | |
| − | + | </pre> | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | Output: | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
Revision as of 17:23, 11 July 2025
function wordToByteTable(Number) : Table
Converts a 16-bit word (integer) to a table of bytes.
Function Parameters
| Parameter | Type | Description |
|---|---|---|
| Number | Integer | The 16-bit word to convert. |
Returns
Table — A table containing the bytes representing the word.
Examples
local bytes = wordToByteTable(0x1234)
for i, b in ipairs(bytes) do
print(string.format("Byte %d: %02X", i, b))
end
-- Output: Byte 1: 34, Byte 2: 12 (little-endian order)
See also
| Lua |
| Script Engine |
Related Functions
| 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 |