Module Types
A general overview over the (custom) data types used throughout this documentation.
Table
table | Every Lua table maps NotNil keys to NotNil values. |
set | A Set is a table in which all values are true and the keys are the actual values. |
PseudoSet | Different from a strict set a PseudoSet considers all keys with NotNil values as elements of itself. |
DenseArray | See array below. |
array | An array - sometimes also called a DenseArray - is a table in which all keys are non-zero NaturalNumbers. |
SparseArray | A SparseArray is also a Table in which all keys are NaturalNumbers. |
EmptyArray | An array that contains no key→value mappings. |
MixedTable | A table that contains both numeric and string keys. |
KeyValuePair | The concept of a key in a table referencing one specific value. |
Number
Number | The basic Lua type for numbers. |
float | A number that has a non-zero decimal fraction. |
Integer | A number that does not have a decimal fraction. |
NaturalNumber | An Integer > 0. |
NegativeInteger | An Integer < 0. |
UnitInterval | A float 0 ≤ x ≤ 1. |
String
Pattern | A string containing a Lua Pattern. |
EmptyString | A string of length 0 that has no content. |
Boolean
true | The boolean value true. |
false | The boolean value false. |
truthy | In contexts where an AnyValue is treated as a boolean it is said to be truthy if it evaluates to true, and falsy if it evaluates to false. |
falsy | The opposite of truthy |
Misc
NotNil | Any string, number, boolean, table, function or userdata. |
AnyValue | Any string, number, boolean, table, function, userdata or nil. |
TruthyValue | Any value that when negated twice evaluates to true. |
InputName | The name of a base game input. |
Table
- table
-
Every Lua table maps NotNil keys to NotNil values.
Every specialized table can also be used as a standard Table.
Fields:
- key NotNil
Usage:
local table = {key = value}
- set
-
A Set is a table in which all values are true and
the keys are the actual values. This is useful to quickly test if a given key
is in a Set or not.
Fields:
- key true
Usage:
local set = {} for _,value in pairs(Table) do set[value] = true end
if set[key] then f() end
for value,_ in pairs(set) do print(value) end
- PseudoSet
-
Different from a strict set a PseudoSet considers all keys with
NotNil values as elements of itself. Thus every Lua table can be
treated as a PseudoSet.
Fields:
- key NotNil
- DenseArray
- See array below.
- array
-
An array - sometimes also called a DenseArray - is a table
in which all keys are non-zero NaturalNumbers. Additionally
the sequence of numbers must be uninterrupted - for every
key n in the array there must also be a key n-1, except for n=1 which
must be the first key (or the array is empty).
Arrays are the ONLY type of Table for which the Lua length operator # reports the correct number of elements. For all other types of Table table_size() must be used.
Fields:
Usage:
for i=1,#array do print(array[i]) end
local A = {'a','b','c','d','e'} print(#A) > 5
- SparseArray
-
A SparseArray is also a Table in which all keys are NaturalNumbers.
Contrary to an Array the sequence of keys may be discontinuous.
Tautologically any function that expects a SparseArray can also take a DenseArray.
These are often used to store entities indexed by their unit_number.
Fields:
Usage:
local entities = {[entity.unit_number] = entity}
- EmptyArray
-
An array that contains no key→value mappings. Remember that Lua tables have
identity and thus empty tables are not primitively equal.
Usage:
local empty = {}
if {} ~= {} then print("Similar but not the same!") end > Similar but not the same!
- MixedTable
-
A table that contains both numeric and string keys.
Fields:
Usage:
local my_table = {'val1','val2','val3',description='MyMixedTable'}
- KeyValuePair
-
The concept of a key in a table referencing one specific value.
When any lua table contains a value that value can be accessed only by it's key.
Any lua table is thus said to be a mapping of multiple keys to one value each. Each key is said to map a value. Each key and it's value form a KeyValuePair.
In lua both keys and values must be NotNil to be considered "in" the table for example for iteration with pairs. All keys that are not "in" the table map to nil. Only keys "in" the table contribute to the size of a table.
Usage:
local my_table = {[key] = value} -- a table with one KeyValuePair
Number
- Number
- The basic Lua type for numbers. It can be any Integer or float.
- float
-
A number that has a non-zero decimal fraction.
Usage:
local float = 3.14159
- Integer
-
A number that does not have a decimal fraction.
Usage:
local Integer = 42
- NaturalNumber
- An Integer > 0. Also called a PositiveInteger.
- NegativeInteger
- An Integer < 0.
- UnitInterval
- A float 0 ≤ x ≤ 1. Often used for probability values. See also Unit interval.
String
- Pattern
- A string containing a Lua Pattern. Not to be confused with Regular Expessions.
- EmptyString
- A string of length 0 that has no content.
Boolean
- true
- The boolean value true.
- false
- The boolean value false.
- truthy
-
In contexts where an AnyValue is treated as a boolean it is said
to be truthy if it evaluates to true, and falsy if it evaluates to false.
This means that doubly-negating the value will convert it to true.
In Lua this applies to any string, number, true, table, function or
userdata. But not false or nil.
Usage:
if (0 and '' and {}) then print('truthy!') end > truthy!
if not nil then print('negation of falsy is true!') end > negation of falsy is true!
print( (not not TruthyValue) == true ) > true
- falsy
- The opposite of truthy
Misc
- NotNil
- Any string, number, boolean, table, function or userdata.
- AnyValue
- Any string, number, boolean, table, function, userdata or nil.
- TruthyValue
-
Any value that when negated twice evaluates to true.
See also:
- InputName
-
The name of a base game input. Usable with Data.SimpleLinkedInput.
Depending on context they're either called input or control.Usage:
-- Factorio Version 1.1.32 -- Extracted from [controls] section of \data\core\locale\en\core.cfg There are currently 149 different controls. 'move-up' , 'move-right' , 'move-down' , 'move-left' , 'shoot-enemy' , 'shoot-selected' , 'open-character-gui' , 'open-technology-gui' , 'rotate' , 'reverse-rotate' , 'flip-blueprint-horizontal' , 'flip-blueprint-vertical' , 'pick-items' , 'confirm-gui' , 'cycle-blueprint-forwards' , 'cycle-blueprint-backwards' , 'cycle-clipboard-forwards' , 'cycle-clipboard-backwards' , 'zoom-in' , 'zoom-out' , 'alt-zoom-in' , 'alt-zoom-out' , 'toggle-menu' , 'production-statistics' , 'kill-statistics' , 'toggle-map' , 'toggle-driving' , 'clear-cursor' , 'smart-pipette' , 'mine' , 'select-for-blueprint' , 'select-for-cancel-deconstruct' , 'reverse-select' , 'build' , 'copy-entity-settings' , 'paste-entity-settings' , 'copy' , 'cut' , 'paste' , 'undo' , 'remove-pole-cables' , 'build-ghost' , 'build-with-obstacle-avoidance' , 'open-gui' , 'drop-cursor' , 'pick-item' , 'cursor-split' , 'stack-transfer' , 'stack-split' , 'inventory-transfer' , 'fast-entity-transfer' , 'inventory-split' , 'fast-entity-split' , 'craft' , 'craft-5' , 'craft-all' , 'cancel-craft' , 'cancel-craft-5' , 'cancel-craft-all' , 'quick-bar-button-1' , 'quick-bar-button-2' , 'quick-bar-button-3' , 'quick-bar-button-4' , 'quick-bar-button-5' , 'quick-bar-button-6' , 'quick-bar-button-7' , 'quick-bar-button-8' , 'quick-bar-button-9' , 'quick-bar-button-10' , 'quick-bar-button-1-secondary' , 'quick-bar-button-2-secondary' , 'quick-bar-button-3-secondary' , 'quick-bar-button-4-secondary' , 'quick-bar-button-5-secondary' , 'quick-bar-button-6-secondary' , 'quick-bar-button-7-secondary' , 'quick-bar-button-8-secondary' , 'quick-bar-button-9-secondary' , 'quick-bar-button-10-secondary' , 'action-bar-select-page-1' , 'action-bar-select-page-2' , 'action-bar-select-page-3' , 'action-bar-select-page-4' , 'action-bar-select-page-5' , 'action-bar-select-page-6' , 'action-bar-select-page-7' , 'action-bar-select-page-8' , 'action-bar-select-page-9' , 'action-bar-select-page-10' , 'rotate-active-quick-bars' , 'next-active-quick-bar' , 'previous-active-quick-bar' , 'toggle-filter' , 'show-info' , 'next-weapon' , 'activate-tooltip' , 'confirm-message' , 'connect-train' , 'disconnect-train' , 'editor-clone-item' , 'editor-delete-item' , 'editor-next-variation' , 'editor-previous-variation' , 'editor-toggle-pause' , 'editor-tick-once' , 'pause-game' , 'editor-speed-up' , 'editor-speed-down' , 'editor-reset-speed' , 'editor-set-clone-brush-source' , 'editor-set-clone-brush-destination' , 'editor-switch-to-surface' , 'editor-remove-scripting-object' , 'open-item' , 'add-station' , 'add-temporary-station' , 'toggle-console' , 'drag-map' , 'place-ping' , 'place-in-chat' , 'larger-terrain-building-area' , 'smaller-terrain-building-area' , 'not-set' , 'unknown' , 'focus-search' , 'previous-technology' , 'previous-mod' , 'logistic-networks' , 'toggle-blueprint-library' , 'open-trains-gui' , 'debug-toggle-atlas-gui' , 'debug-toggle-debug-settings' , 'debug-toggle-basic' , 'debug-reset-zoom' , 'debug-reset-zoom-2x' , 'controller-gui-crafting-tab' , 'controller-gui-logistics-tab' , 'controller-gui-character-tab' , 'toggle-gui-debug' , 'toggle-gui-style-view' , 'toggle-gui-shadows' , 'toggle-gui-glows' , 'open-prototypes-gui' , 'open-prototype-explorer-gui' , 'increase-ui-scale' , 'decrease-ui-scale' , 'reset-ui-scale' , 'next-player-in-replay' , 'order-to-follow' , ,