> For the complete documentation index, see [llms.txt](https://wecon.gitbook.io/pistudio-manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wecon.gitbook.io/pistudio-manual/9.-scripts/lua-script.md).

# Lua script

Lua is commonly described as a "[multi-paradigm](https://en.wikipedia.org/wiki/Multi-paradigm_programming_language)" language, providing a small set of general features that can be extended to fit different problem types. Lua does not contain explicit support for [inheritance](https://en.wikipedia.org/wiki/Inheritance_\(object-oriented_programming\)), but allows it to be implemented with [metatables](https://en.wikipedia.org/wiki/Metatable). Similarly, Lua allows programmers to implement [namespaces](https://en.wikipedia.org/wiki/Namespaces), [classes](https://en.wikipedia.org/wiki/Class_\(computer_science\)), and other related features using its single table implementation; [first-class functions](https://en.wikipedia.org/wiki/First-class_function) allow the employment of many techniques from [functional programming](https://en.wikipedia.org/wiki/Functional_programming); and full lexical [scoping](https://en.wikipedia.org/wiki/Scope_\(programming\)) allows fine-grained [information hiding](https://en.wikipedia.org/wiki/Information_hiding) to enforce the [principle of least privilege](https://en.wikipedia.org/wiki/Principle_of_least_privilege).

In general, Lua strives to provide simple, flexible [meta-features](https://en.wikipedia.org/wiki/Metaprogramming) that can be extended as needed, rather than supply a feature-set specific to one programming paradigm. As a result, the base language is [light](https://en.wikipedia.org/wiki/Lightweight_programming_language)—the full reference [interpreter](https://en.wikipedia.org/wiki/Interpreter_\(computing\)) is only about 247 [kB](https://en.wikipedia.org/wiki/Kilobyte) compiled[\[3\]](https://en.wikipedia.org/wiki/Lua_\(programming_language\)#cite_note-luaabout-4)—and easily adaptable to a broad range of applications.

Lua is a [dynamically typed](https://en.wikipedia.org/wiki/Dynamically_typed) language intended for use as an [extension](https://en.wikipedia.org/wiki/Scripting_language) or [scripting language](https://en.wikipedia.org/wiki/Scripting_language) and is compact enough to fit on a variety of host platforms. It supports only a small number of atomic data structures such as [boolean](https://en.wikipedia.org/wiki/Boolean_data_type) values, numbers (double-precision [floating point](https://en.wikipedia.org/wiki/Floating_point) and 64-bit [integers](https://en.wikipedia.org/wiki/Integers) by default), and [strings](https://en.wikipedia.org/wiki/String_\(computer_science\)). Typical data structures such as [arrays](https://en.wikipedia.org/wiki/Array_data_structure), [sets](https://en.wikipedia.org/wiki/Set_\(computer_science\)), [lists](https://en.wikipedia.org/wiki/List_\(computing\)), and [records](https://en.wikipedia.org/wiki/Record_\(computer_science\)) can be represented using Lua's single native data structure, the table, which is essentially a heterogeneous [associative array](https://en.wikipedia.org/wiki/Associative_array).

Lua implements a small set of advanced features such as [first-class functions](https://en.wikipedia.org/wiki/First-class_function), [garbage collection](https://en.wikipedia.org/wiki/Garbage_collection_\(computer_science\)), [closures](https://en.wikipedia.org/wiki/Closure_\(computer_science\)), proper [tail calls](https://en.wikipedia.org/wiki/Tail_recursion), [coercion](https://en.wikipedia.org/wiki/Type_conversion) (automatic conversion between string and number values at run time), [coroutines](https://en.wikipedia.org/wiki/Coroutine) (cooperative multitasking) and [dynamic module loading](https://en.wikipedia.org/wiki/Dynamic_loading).
