Questions tagged [lua]

Lua is a powerful, fast, lightweight, embeddable scripting language. It is dynamically typed, runs by interpreting bytecode, and has automatic garbage collection. Its speed is one of the main reasons it is widely used by the machine learning community. It is often referred to as an "extensible extension language".

This tag is used for questions about the Lua programming language.

From Lua's About page:

What is Lua?

Lua is a powerful, fast, lightweight, embeddable scripting language.

Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.

The official implementation of Lua is written in clean ANSI C, but a list of several other implementations can be found on the Lua Users Wiki page on Lua Implementations.

The latest official version of Lua is 5.4.1. The previous minor version (5.3.6) is available in the version history on the official site. Lua version numbers are defined as follows: major.minor.bugfix. Minor version increases will often no longer be backwards compatible with prior minor versions.

Lua is certified Open Source software distributed under the terms of the MIT license. As such, Lua is free to use, even for commercial products.

Please note that the official name of this programming language is Lua (a Portuguese word for Earth's moon). It is not an acronym -- it is not spelled LUA.

Learning Lua

Resources

  • Lua.org - The official Lua site.
  • LuaJIT - A fast tracing Just-In-Time compiler for Lua 5.1.
  • LuaRocks - the package manager for Lua modules.
  • ZeroBrane Studio - An IDE and debugger supporting a variety of Lua systems.
  • Lua Development Tools - An Eclipse-based IDE and debugger.
  • LuaDist - Lua modules management system with Virtual Environment capabilities.

Some projects using Lua

  • Torch - A scientific computing framework based on Lua[JIT] with strong CPU and CUDA backends.
  • lua-alchemy - Port of the Lua programming language for ActionScript using Alchemy.
  • Nutria - PHP Standard Library Written in Lua Programming Language
  • Sputnik - A content management system designed for extensibility.

Community

Other places for discussing Lua, beyond the question & answer format of Stack Overflow:

Books

22266 questions
39
votes
7 answers

Lua need to split at comma

I've googled and I'm just not getting it. Seems like such a simple function, but of course Lua doesn't have it. In Python I would do string = "cat,dog" one, two = string.split(",") and then I would have two variables, one = cat. two = dog How do I…
Jaron Bradley
  • 1,079
  • 3
  • 16
  • 24
38
votes
17 answers

Solving random crashes

I am getting random crashes on my C++ application, it may not crash for a month, and then crash 10 times in a hour, and sometimes it may crash on launch, while sometimes it may crash after several hours of operation (or not crash at all). I use GCC…
speeder
  • 6,197
  • 5
  • 34
  • 51
38
votes
3 answers

Check if array contains specific value

I have this array, with some values (int) and I want to check if a value given by the user is equal to a value in that string. If it is, output a message like "Got your string". Example of the list: local op = { {19}, {18}, {17} } if 13 == (the…
Ether Metin
  • 391
  • 1
  • 3
  • 4
38
votes
4 answers

Lua - Reflection - Get list of functions/fields on an object?

I'm new to Lua and dealing with Lua as a scripting language in an alpha release of a program. The developer is unresponsive and I need to get a list of functions provided by some C++ objects which are accessible from the Lua code. Is there any easy…
luanoob
  • 383
  • 1
  • 3
  • 4
38
votes
1 answer

current line number in Lua

Does Lua support something like C's __LINE__ macro, which returns the number of the current code line? I know Lua has a special built-in variable called _G, but I don't see line number in there...
prideout
  • 2,895
  • 1
  • 23
  • 25
38
votes
5 answers

What can I do to increase the performance of a Lua program?

I asked a question about Lua perfromance, and on of the responses asked: Have you studied general tips for keeping Lua performance high? i.e. know table creation and rather reuse a table than create a new one, use of 'local print=print' and such to…
Jon 'links in bio' Ericson
  • 20,880
  • 12
  • 98
  • 148
37
votes
8 answers

How to get list of directories in Lua

I need a list of directory in LUA Suppose I have a directory path as "C:\Program Files" I need a list of all the folders in that particular path and how to search any particular folder in that list. Example Need a list of all the folder in path…
che
  • 485
  • 2
  • 6
  • 7
37
votes
3 answers

What are Lua coroutines even for? Why doesn't this code work as I expect it?

I'm having trouble understanding this code... I was expecting something similar to threading where I would get an output with random "nooo" and "yaaaay"s interspersed with each other as they both do the printing asynchronously, but rather I…
kellpossible
  • 663
  • 1
  • 8
  • 19
37
votes
2 answers

How do you cleanly exit interactive Lua?

I've tried to the word "quit" on a single line but this seems to simply change the command line pointer from a ">" to a ">>". What's the best way to end a session in interactive Lua please?
James Bedford
  • 28,702
  • 8
  • 57
  • 64
37
votes
20 answers

Easiest way to make lua script wait/pause/sleep/block for a few seconds?

I cant figure out how to get lua to do any common timing tricks, such as sleep - stop all action on thread pause/wait - don't go on to the next command, but allow other code in the application to continue block - don't go on to next command until…
MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
36
votes
4 answers

Lua vs Embedded Lisp and potential other candidates. for set based data processing

Current Choice: lua-jit. Impressive benchmarks, I am getting used to the syntax. Writing a high performance ABI will require careful consideration on how I will structure my C++. Other Questions of interest Gambit-C and Guile as embeddable…
Hassan Syed
  • 20,075
  • 11
  • 87
  • 171
36
votes
6 answers

What multithreading package for Lua "just works" as shipped?

Coding in Lua, I have a triply nested loop that goes through 6000 iterations. All 6000 iterations are independent and can easily be parallelized. What threads package for Lua compiles out of the box and gets decent parallel speedups on four or…
Norman Ramsey
  • 198,648
  • 61
  • 360
  • 533
36
votes
4 answers

No package 'lua' found but i have it installed

I'm trying to install Lsyncd on Ubuntu 10.4 LTS but i get some error : > checking for LUA... no checking for > LUA... no checking for LUA... > configure: error: Package requirements > (lua >= 5.1.3) were not met: > > No package 'lua' found > >…
bru
  • 383
  • 1
  • 3
  • 8
35
votes
1 answer

Lua's package management system?

What's the Lua's standard package management system and repository? Like brew for Mac OS X, npm for node.js.
eonil
  • 83,476
  • 81
  • 317
  • 516
35
votes
1 answer

Capabilities for Lua: what experience is there?

There's been some discussion on the cap-talk mailing list around whether Lua and Javascript support the object-capability model, with the conclusion that because of support for restricting the environment to called functions through setfenv, and the…
Charles Stewart
  • 11,661
  • 4
  • 46
  • 85