Lua:registerCustomTypeAutoAssembler
Jump to navigation
Jump to search
Registers a custom type based on an Auto Assembler script.
The script must allocate and define both a ConvertRoutine and a ConvertBackRoutine. These routines are used to convert the raw bytes into a value and to convert a value back into bytes.
Function Parameters
| Parameter | Type | Description |
|---|---|---|
| script | String | The Auto Assembler script used to define the custom type. The script must allocate ConvertRoutine and ConvertBackRoutine. |
Returns
CustomType — The registered Custom Type object.
Required Routines
| Routine | Description |
|---|---|
| ConvertRoutine | The routine that converts the raw bytes into the value shown by the custom type. |
| ConvertBackRoutine | The routine that converts a value back into the bytes that should be written. |
Examples
local script = [[
alloc(ConvertRoutine, 1024)
alloc(ConvertBackRoutine, 1024)
ConvertRoutine:
// Add conversion code here
ret
ConvertBackRoutine:
// Add conversion-back code here
ret
]]
local customType = registerCustomTypeAutoAssembler(script)
print("Registered custom type: " .. tostring(customType)) -- ??