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
5
votes
2 answers

Atomically move redis key on expiration

Is there a way to atomically move a redis key from one place to another when it expires? There's ways of doing this in the client by being notified of redis expire notifications, but if no clients are running when the notification is triggered then…
user779159
  • 9,034
  • 14
  • 59
  • 89
5
votes
3 answers

Love2D: what is the difference between creating variables inside love.load instead of at the top of the main.lua file?

If you look at the docs for love.load it says This function is called exactly once at the beginning of the game. and nothing else really. Also it has one parameter, which are command line args. So if you don't use the args, what is the difference…
m0meni
  • 16,006
  • 16
  • 82
  • 141
5
votes
2 answers

Dictionary based switch-like statement with actions

I'm relatively new to Python and would like to know if I'm reinventing a wheel or do things in a non-pythonic way - read wrong. I'm rewriting some parser originally written in Lua. There is one function which accepts a field name from imported table…
David Unric
  • 7,421
  • 1
  • 37
  • 65
5
votes
1 answer

Lua cannot find installed luarocks on Ubuntu

I install luarocks: $ sudo apt-get install luarocks I install lua-cjson by luarocks: $sudo luarocks install lua-cjson show packages: $luarocks list Installed rocks: ---------------- lua-cjson 2.1.0-1 (installed) -…
Alexandre Kalendarev
  • 681
  • 2
  • 10
  • 24
5
votes
2 answers

n-digit Pattern Matching in Lua

I'm new to Lua. Say i have a string "1234567890". I want to iterate over all possible 3 digit numbers. (ie 123,234,345,456....) for m in string.gmatch("1234567890","%d%d%d") do print (m) end But this gives me the output 123,456,789. What…
st0le
  • 33,375
  • 8
  • 89
  • 89
5
votes
3 answers

Can I make function `extern "c"`?

I have some cpp files, and I want to combine them with LuaJit using FFI. But the problem is that, I have to add extern "c" symbols for almost every function to make it possible for FFI to access them. Is there a simpler way to make this done?
Zehui Lin
  • 186
  • 9
5
votes
4 answers

Can 32bit Lua bytecode work on a 64bit system?

Can a compiled Lua file (32bit *.luac file) work on a 64 Bit system?
luac
  • 51
  • 1
  • 2
5
votes
1 answer

Lua Ellipsis Expression limited at 248

I am learning Lua for a university class in mobile application development and recently we covered the ellipsis operator (...) allowing a dynamic amount of arguments. Out of curiosity I decided to try and find out if there was a limit to how many…
Rhexis
  • 2,414
  • 4
  • 28
  • 40
5
votes
1 answer

Call an anonymous function with a local variable as parameter

I have a function that creates an object (in this case, a Hammerspoon Notify object), and I would like to pass this object as the parameter to an anonymous function that is itself an argument to a function call. That's a very convoluted explanation,…
Mikayla
  • 73
  • 6
5
votes
1 answer

Lua error handling

I'm new to lua. I've tried to use http://keplerproject.github.io/luafilesystem/examples.html and it throws an error on inaccessible directories. This appears to be caused by luaL_error…
Petr Skocik
  • 58,047
  • 6
  • 95
  • 142
5
votes
1 answer

How to create Lua table with name C-API

How to create Lua table from C-API like this: TableName = {a, b, c} How to set table name? I only know how to create table and put values, but don't know how to set name of table. Code for creating table without name: lua_createtable(L, 0,…
BORSHEVIK
  • 794
  • 1
  • 8
  • 12
5
votes
1 answer

luaSocket HTTP requests always respond with a redirect (301 or 302)

I use LuaForWindows (latest version) and I have read this and this answer and everything i could find in the mailinglist of lua-users.org. What ever I try (most) sites only respond with either 301 or 302. I have created an example batch script which…
tDwtp
  • 480
  • 5
  • 12
5
votes
2 answers

How do i convert binary to decimal (LUA)

I know that there's tonumber() function, but the problem is that i need to convert larger numbers like 1000100110100011111010101001001001001100100101 . I can write that by myself, but is there a way to integrate that in function? And if I write that…
Di1997
  • 119
  • 1
  • 2
  • 13
5
votes
1 answer

what is the best way to generate random pattern inside of a table

I'v got a table (2d array), c x r. Need to generate a random pattern of connected cells inside of it. No self-crossings and no diagonal-moves. See related picture for example. ex. 1 с = 6, r = 7, the pattern is shown in numbers. I'w wrote a…
Aleksei
  • 57
  • 6
5
votes
2 answers

Lua emulating the require function

In the embeded lua environment (World of Warcraft - WoW) is missing the require function. I want port one existing lua source code (an great OO-library) for the use it in the WoW. The library itself is relatively small (approx 8 small files) but of…
cajwine
  • 3,100
  • 1
  • 20
  • 41