<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.cheatengine.org/index.php?action=history&amp;feed=atom&amp;title=Lua%3AClass%3ACustomType</id>
	<title>Lua:Class:CustomType - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.cheatengine.org/index.php?action=history&amp;feed=atom&amp;title=Lua%3AClass%3ACustomType"/>
	<link rel="alternate" type="text/html" href="https://wiki.cheatengine.org/index.php?title=Lua:Class:CustomType&amp;action=history"/>
	<updated>2026-06-26T11:36:09Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.32.0</generator>
	<entry>
		<id>https://wiki.cheatengine.org/index.php?title=Lua:Class:CustomType&amp;diff=7998&amp;oldid=prev</id>
		<title>Leunsel: Class Template Implementation.</title>
		<link rel="alternate" type="text/html" href="https://wiki.cheatengine.org/index.php?title=Lua:Class:CustomType&amp;diff=7998&amp;oldid=prev"/>
		<updated>2026-06-23T18:22:05Z</updated>

		<summary type="html">&lt;p&gt;Class Template Implementation.&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 18:22, 23 June 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Lua]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Lua]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;CodeBox&lt;/del&gt;|'''class''' CustomType ''':''' Object}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Class&lt;/ins&gt;|'''class''' CustomType ''':''' Object}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The CustomType class represents a converter that translates raw data into a human-readable interpretation.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The CustomType class represents a converter that translates raw data into a human-readable interpretation.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Leunsel</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.cheatengine.org/index.php?title=Lua:Class:CustomType&amp;diff=7992&amp;oldid=prev</id>
		<title>Leunsel: Initial page creation.</title>
		<link rel="alternate" type="text/html" href="https://wiki.cheatengine.org/index.php?title=Lua:Class:CustomType&amp;diff=7992&amp;oldid=prev"/>
		<updated>2026-06-21T17:07:11Z</updated>

		<summary type="html">&lt;p&gt;Initial page creation.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Lua]]&lt;br /&gt;
{{CodeBox|'''class''' CustomType ''':''' Object}}&lt;br /&gt;
&lt;br /&gt;
The CustomType class represents a converter that translates raw data into a human-readable interpretation.&lt;br /&gt;
&lt;br /&gt;
Custom types can be registered through Lua functions or through an Auto Assembler script. Once registered, the CustomType object can convert byte tables to values and values back to byte tables.&lt;br /&gt;
&lt;br /&gt;
===Inheritance===&lt;br /&gt;
{|width=&amp;quot;85%&amp;quot; cellpadding=&amp;quot;10%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Class&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Inherits From&lt;br /&gt;
!style=&amp;quot;width: 80%;background-color:white;&amp;quot; align=&amp;quot;left&amp;quot;|Description&lt;br /&gt;
|-&lt;br /&gt;
|CustomType&lt;br /&gt;
|Object&lt;br /&gt;
|A converter for interpreting raw data as human-readable values.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Global Functions===&lt;br /&gt;
{|width=&amp;quot;85%&amp;quot; cellpadding=&amp;quot;10%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Function&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Return Type&lt;br /&gt;
!style=&amp;quot;width: 80%;background-color:white;&amp;quot; align=&amp;quot;left&amp;quot;|Description&lt;br /&gt;
|-&lt;br /&gt;
|registerCustomTypeLua(typename, bytecount, bytestovaluefunction, valuetobytesfunction, isFloat)&lt;br /&gt;
|CustomType&lt;br /&gt;
|Registers a custom type based on Lua functions.&lt;br /&gt;
|-&lt;br /&gt;
|registerCustomTypeAutoAssembler(script)&lt;br /&gt;
|CustomType&lt;br /&gt;
|Registers a custom type based on an Auto Assembler script. The script must allocate ConvertRoutine and ConvertBackRoutine.&lt;br /&gt;
|-&lt;br /&gt;
|getCustomType(typename)&lt;br /&gt;
|CustomType or nil&lt;br /&gt;
|Returns the custom type object with the specified name, or nil if it could not be found.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Properties===&lt;br /&gt;
{|width=&amp;quot;85%&amp;quot; cellpadding=&amp;quot;10%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Property&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Type&lt;br /&gt;
!style=&amp;quot;width: 80%;background-color:white;&amp;quot; align=&amp;quot;left&amp;quot;|Description&lt;br /&gt;
|-&lt;br /&gt;
|name&lt;br /&gt;
|String&lt;br /&gt;
|The name of the custom type.&lt;br /&gt;
|-&lt;br /&gt;
|functiontypename&lt;br /&gt;
|String&lt;br /&gt;
|The function type name of the custom type.&lt;br /&gt;
|-&lt;br /&gt;
|CustomTypeType&lt;br /&gt;
|TCustomTypeType&lt;br /&gt;
|The type of script used by the custom type.&lt;br /&gt;
|-&lt;br /&gt;
|script&lt;br /&gt;
|String&lt;br /&gt;
|The custom type script.&lt;br /&gt;
|-&lt;br /&gt;
|scriptUsesFloat&lt;br /&gt;
|Boolean&lt;br /&gt;
|True if the script interprets user-side values as floating-point values.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
{|width=&amp;quot;85%&amp;quot; cellpadding=&amp;quot;10%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Method&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Return Type&lt;br /&gt;
!style=&amp;quot;width: 80%;background-color:white;&amp;quot; align=&amp;quot;left&amp;quot;|Description&lt;br /&gt;
|-&lt;br /&gt;
|byteTableToValue({bytetable}, Address)&lt;br /&gt;
|Integer or Number&lt;br /&gt;
|Converts a table of bytes into the interpreted value. Address is optional.&lt;br /&gt;
|-&lt;br /&gt;
|valueToByteTable(value, Address)&lt;br /&gt;
|Table&lt;br /&gt;
|Converts a value into a table of bytes. Address is optional.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===registerCustomTypeLua===&lt;br /&gt;
{{CodeBox|'''function''' registerCustomTypeLua(''typename'', ''bytecount'', ''bytestovaluefunction'', ''valuetobytesfunction'', ''isFloat'') ''':''' CustomType}}&lt;br /&gt;
&lt;br /&gt;
Registers a custom type based on Lua functions.&lt;br /&gt;
&lt;br /&gt;
The bytes-to-value function should be defined as a function that receives the bytes as separate parameters and returns an integer value.&lt;br /&gt;
&lt;br /&gt;
The value-to-bytes function should be defined as a function that receives an integer value and returns the bytes that should be written.&lt;br /&gt;
&lt;br /&gt;
===registerCustomTypeLua Parameters===&lt;br /&gt;
{|width=&amp;quot;85%&amp;quot; cellpadding=&amp;quot;10%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Parameter&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Type&lt;br /&gt;
!style=&amp;quot;width: 80%;background-color:white;&amp;quot; align=&amp;quot;left&amp;quot;|Description&lt;br /&gt;
|-&lt;br /&gt;
|typename&lt;br /&gt;
|String&lt;br /&gt;
|The name of the custom type to register.&lt;br /&gt;
|-&lt;br /&gt;
|bytecount&lt;br /&gt;
|Integer&lt;br /&gt;
|The number of bytes used by this custom type.&lt;br /&gt;
|-&lt;br /&gt;
|bytestovaluefunction&lt;br /&gt;
|Function&lt;br /&gt;
|The function that converts raw bytes into a value.&lt;br /&gt;
|-&lt;br /&gt;
|valuetobytesfunction&lt;br /&gt;
|Function&lt;br /&gt;
|The function that converts a value into the bytes that should be written.&lt;br /&gt;
|-&lt;br /&gt;
|isFloat&lt;br /&gt;
|Boolean&lt;br /&gt;
|If true, the custom type interprets user-side values as floating-point values.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===registerCustomTypeAutoAssembler===&lt;br /&gt;
{{CodeBox|'''function''' registerCustomTypeAutoAssembler(''script'') ''':''' CustomType}}&lt;br /&gt;
&lt;br /&gt;
Registers a custom type based on an Auto Assembler script.&lt;br /&gt;
&lt;br /&gt;
The script must allocate and define both ''ConvertRoutine'' and ''ConvertBackRoutine''.&lt;br /&gt;
&lt;br /&gt;
===registerCustomTypeAutoAssembler Parameters===&lt;br /&gt;
{|width=&amp;quot;85%&amp;quot; cellpadding=&amp;quot;10%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Parameter&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Type&lt;br /&gt;
!style=&amp;quot;width: 80%;background-color:white;&amp;quot; align=&amp;quot;left&amp;quot;|Description&lt;br /&gt;
|-&lt;br /&gt;
|script&lt;br /&gt;
|String&lt;br /&gt;
|The Auto Assembler script used to define the custom type. The script must allocate ConvertRoutine and ConvertBackRoutine.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===getCustomType===&lt;br /&gt;
{{CodeBox|'''function''' getCustomType(''typename'') ''':''' CustomType}}&lt;br /&gt;
&lt;br /&gt;
Returns the custom type object with the specified name, or nil if it could not be found.&lt;br /&gt;
&lt;br /&gt;
===getCustomType Parameters===&lt;br /&gt;
{|width=&amp;quot;85%&amp;quot; cellpadding=&amp;quot;10%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Parameter&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Type&lt;br /&gt;
!style=&amp;quot;width: 80%;background-color:white;&amp;quot; align=&amp;quot;left&amp;quot;|Description&lt;br /&gt;
|-&lt;br /&gt;
|typename&lt;br /&gt;
|String&lt;br /&gt;
|The name of the custom type to retrieve.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local function bytesToValue(b1, b2, b3, b4)&lt;br /&gt;
  return b1 + (b2 * 0x100) + (b3 * 0x10000) + (b4 * 0x1000000)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function valueToBytes(value)&lt;br /&gt;
  local b1 = value % 0x100&lt;br /&gt;
  local b2 = math.floor(value / 0x100) % 0x100&lt;br /&gt;
  local b3 = math.floor(value / 0x10000) % 0x100&lt;br /&gt;
  local b4 = math.floor(value / 0x1000000) % 0x100&lt;br /&gt;
&lt;br /&gt;
  return b1, b2, b3, b4&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local customType = registerCustomTypeLua(&lt;br /&gt;
  &amp;quot;Lua Integer Example&amp;quot;,&lt;br /&gt;
  4,&lt;br /&gt;
  bytesToValue,&lt;br /&gt;
  valueToBytes,&lt;br /&gt;
  false&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;Registered custom type: &amp;quot; .. tostring(customType))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local customType = getCustomType(&amp;quot;Lua Integer Example&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
if customType ~= nil then&lt;br /&gt;
  local value = customType.byteTableToValue({0x78, 0x56, 0x34, 0x12})&lt;br /&gt;
  print(&amp;quot;Value: &amp;quot; .. tostring(value))&lt;br /&gt;
&lt;br /&gt;
  local bytes = customType.valueToByteTable(value)&lt;br /&gt;
&lt;br /&gt;
  for i = 1, #bytes do&lt;br /&gt;
    print(&amp;quot;Byte &amp;quot; .. i .. &amp;quot;: &amp;quot; .. string.format(&amp;quot;%02X&amp;quot;, bytes[i]))&lt;br /&gt;
  end&lt;br /&gt;
else&lt;br /&gt;
  print(&amp;quot;Custom type not found&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local script = [[&lt;br /&gt;
alloc(ConvertRoutine, 1024)&lt;br /&gt;
alloc(ConvertBackRoutine, 1024)&lt;br /&gt;
&lt;br /&gt;
ConvertRoutine:&lt;br /&gt;
  // Add conversion code here&lt;br /&gt;
  ret&lt;br /&gt;
&lt;br /&gt;
ConvertBackRoutine:&lt;br /&gt;
  // Add conversion-back code here&lt;br /&gt;
  ret&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local customType = registerCustomTypeAutoAssembler(script)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;Registered custom type: &amp;quot; .. tostring(customType))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{LuaSeeAlso}}&lt;/div&gt;</summary>
		<author><name>Leunsel</name></author>
		
	</entry>
</feed>