# Built-in Lua types

For more information on how these types are handled, please check the official Lua 5.1 Reference Manual.

In the API reference, types surrounded by {curly brackets} means a table of said type.

## boolean

A `boolean`

is a logical value that can be either `true`

or `false`

. This can be used to evaluate logic, for example using comparators between two values returns a boolean. In module states, `true`

means "on", "active" or "pressed", while `false`

means the opposite.

```
local playerCanMove = false
-- sets a boolean called "playerCanMove" to false
gdt.Led0.State = true
-- sets the "State" of a LED to true, turning it on
```

## number

A `number`

refers to any sort of numerical value, integer or floating point.

```
local pi = 3.14159
-- sets a number called "pi" to 3.14159
local knobValue = gdt.Knob0.Value
-- sets a number called "knobValue" to the "Value" property of a knob
```

## string

A `string`

is a type that holds a text value (a string of characters). See the Lua documentation for various built-in functions to manipulate strings.

```
local message = "Hello world!"
-- sets a string called "message"
log(message)
-- displays the string "message"
```

## table

In Lua, a table is a group of values of a certain type. Tables are described in typing with curly brackets such as `{number}`

for a one-dimensional array, or `{{number}}`

for a two-dimensional matrix.

Tables in Lua are 1-indexed meaning that the first element is numbered 1 and so forth. An example of a two-dimensional table can be manipulated like such:

`variable[column][row]`

where `variable`

is your table, `column`

and `row`

are the indices you want to manipulate.

```
local primes = {1, 3, 5, 7, 9}
-- sets an array called "primes"
log(tostring(primes[2]))
-- displays the second entry of "primes"
```

You can get the size of a table by using `#`

before the name of the table:

```
local mytable = {"a", "b", "c", "d"}
log(tostring(#mytable)) -- returns 4
```

If a table is two-dimensional, you need to use one of the inner tables to measure both dimensions:

```
local mytable = {
{"a", "b"},
{"c", "d"},
{"e", "f"}
}
log(tostring(#mytable)) -- returns 3, number of rows
log(tostring(#mytable[1])) -- returns 2, length of row 1, which tells us the columns
```