Follow TV Tropes

Following

Media Notes / Lua

Go To

https://static.tvtropes.org/pmwiki/pub/images/d238d9f2_81b8_44d1_b584_6c6e6be4be2f.png

Lua is an Imperative, Dynamically and Strongly typed, Multi-Paradigm Programming Language. It is the most commonly used publicly available scripting language in Video Games development. While the Unreal engine's scripting language might be more commonly used, that language is bound to the Unreal engine, while Lua can be used in anything.

You can try Lua out here.

Lua is often used in games for many reasons:

  1. Lua is the smallest scripting language available. It has very little overhead, and its standard library is very small and tight.
  2. Lua is the fastest VM-based scripting language, and even faster as LuaJIT.
  3. Lua, as a language, is very flexible and easy to learn.
  4. Lua, unlike many other publicly available scripting languages, is designed to be embedded in an application. Embedded scripting languages offer a degree of developer control that non-embedded languages lack.
  5. On top of being easily embedded, Lua is easily extended, with a simple API used for both that can be used to make Lua interface modules for any C library. (This allows, for instance, an external window using the IUP UI library to control an NES game running in the FCEUX emulator, which has Lua embedded.)
  6. Unlike almost all other open source projects, Lua (and other projects in its culture) has no "copyleft" clause (under the MIT license), meaning that you are free to do whatever you want with derivative works that use it, including selling them without disclosing the source code.


    Code Examples 

Hello Lua

print("Hello World!")

Outputs Hello World! to the console. Can also be written as print 'Hello World!'

Variable Declarations and Concatenation

a = 10
b = 7
c = "hi"
print(a + b)
— Outputs 17
print(b .. c)
— Outputs 7hi
print("Hello and " .. c)
— Outputs Hello and hi

Lua is unique in that it has a unique operator dedicated to concatenating. Making the + operator only for addition.

For Loops

for i = 0,9,1 do
    print(i)
end

Works That Use Lua

    Video Games 
  • Garry's Mod
  • PAYDAY 2 uses Lua for all of its systems. Modders can use the SuperBLT Lua hook to overwrite it with other files, enabling many kinds of mods.
  • Sonic Unleashed
    Game Engines 
  • LÖVE, a popular open-source engine for 2D games, uses Lua.
  • PICO-8 games are all coded in a variant of Lua (some alternative syntax is provided, and the Lua standard libraries are replaced with PICO-8's own set of functions).
  • Roblox: Programming language for the game creation system, so all games are scripted with Lua.

It's important to note that the name of the language is "Lua", not "LUA". It is not an acronym, but rather the Portugese word for "moon", as Lua was developed in Brazil.


Top