Wiki Page, Programming School: Lesson 2: Variables and types

Wiki Page
2017-01-27T10:56:12-07:00

There are multiple types of variables. Integers, Strings, Arrays (lists), and Objects. Each do different things.

Integers store only numbers, so you can't use it like a string.

Strings store text, so you can't add it together (they can be joined though). If a is "1" and b is "1", you can't do a+b and expect to get "2", you'd get an error. If you did a..b however, you'd get "11".

Arrays act like lists. They store multiple pieces of data in one variable. They are defined like this:
array = {"info", "info2"}

To access the first piece of data in an array, you would do this:

array[0]

and increment the 0 by 1 to read the next item.

Objects store information about an object in Lua. This applies in ROBLOX and will not be covered until the ROBLOX unit.