--- title: table - Tables and methods summary: Tables store key-value pairs. Sequence indices normally start at 1. object:run(x) means object.run(object, x): the colon passes self. A table does not automatically gain game methods. section: reference kind: guide status: reference updated: 2026-10-26 tags: ["API","X4"] sources: ["https://wiki.egosoft.com/X4%20Foundations%20Wiki/Modding%20Support/","https://www.lua.org/manual/5.1/manual.html","https://luajit.org/ext_ffi_api.html"] --- ## Meaning Tables store key-value pairs. Sequence indices normally start at 1. object:run(x) means object.run(object, x): the colon passes self. A table does not automatically gain game methods. ## Example ```lua local object = {count = 0} function object:add(value) self.count = self.count + value end object:add(2) local values = {"a", "b"} local text = table.concat(values, ", ") ``` **What happens:** object.count = 2; text = "a, b"; the colon passes object as self. This fragment does not print or write a log message. The values shown are the expected results of the example. ## Methods and related calls | Function | Returns | Purpose | | --- | --- | --- | | [table.concat](wiki:api-standard-table-concat-59959ede) | [`string`](wiki:type-string) | Joins string or numeric sequence elements with a separator. | | [table.insert](wiki:api-standard-table-insert-fdeedf14) | [`none`](wiki:type-results) | Inserts a sequence value and shifts elements; an omitted position appends it. | | [table.remove](wiki:api-standard-table-remove-f70112c3) | [`any`](wiki:type-results) \| [`nil`](wiki:type-nil) | Removes and returns a sequence element, shifting later values; defaults to the last element. | | [table.sort](wiki:api-standard-table-sort-34b8a577) | [`none`](wiki:type-results) | Sorts a sequence in place; a comparator must define a strict order. | | [table.unpack](wiki:api-standard-table-unpack-01fac384) | [`any`](wiki:type-results), ... | Expands a sequence range into multiple results; requires the compatibility extension to be available. |