Lua:registerCustomTypeLua
Jump to navigation
Jump to search
function registerCustomTypeLua(TypeName, ByteCount, BytesToValueFunction, ValueToBytesFunction, [IsFloat]) : CustomType
Registers a custom value type for Cheat Engine memory records, using Lua functions for conversion between bytes and values.
The bytes-to-value function should be defined as function bytestovalue(b1, b2, ...)
and return the interpreted value.
The value-to-bytes function should be defined as function valuetobytes(value)
and return the bytes to write (as multiple return values).
Function Parameters[edit]
Parameter | Type | Description |
---|---|---|
TypeName | String | The name of the custom type. |
ByteCount | Integer | The number of bytes this type occupies. |
BytesToValueFunction | Function | A Lua function that takes ByteCount arguments and returns the interpreted value.
|
ValueToBytesFunction | Function | A Lua function that takes a value and returns ByteCount bytes (as multiple return values).
|
IsFloat | Boolean (optional) | Set to true if the type should be treated as a floating point value. |
Returns[edit]
CustomType — The registered custom type object.
Examples[edit]
-- Example: Register a 3-byte integer type function myBytesToValue(b1, b2, b3) return b1 + (b2 << 8) + (b3 << 16) end function myValueToBytes(val) local b1 = val & 0xFF local b2 = (val >> 8) & 0xFF local b3 = (val >> 16) & 0xFF return b1, b2, b3 end local myType = registerCustomTypeLua("3ByteInt", 3, myBytesToValue, myValueToBytes)