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

How do I use MySQL for dynamic doc root with Nginx?

I've been trying to find out a way to first capture environment variable HOSTNAME and then use a MySQL query to fetch and return back to the Nginx conf the document root for our vhosts. We use them for dynamic doc roots currently in Apache but are…
user2782387
  • 101
  • 1
  • 6
5
votes
4 answers

Lua on the iPhone

I'm trying to load at run-time Lua scripts on the iPhone. Is there a possibility to do that? How can I getting started with Lua? I can't find something. The only thing I can find is that this should be possible, but I am wondering how.
Fabrizio Farinelli
  • 241
  • 1
  • 4
  • 8
5
votes
1 answer

Lua table length function override not working

How does one change the length operator (#) for a table in Lua, the manual suggests assigning the __len function in a metatable and then assigning that metatable to the table I want to override, but this doesn't work as expected? I do not have the…
fisherdog1
  • 65
  • 5
5
votes
2 answers

What is the convention to document types used in Lua?

I come from the strongly typed world and I want to write some Lua code. How should I document what type things are? What do Lua natives do? Hungarian notation? Something else? For example: local insert = function(what, where, offset) It's…
Ansis Māliņš
  • 1,684
  • 15
  • 35
5
votes
2 answers

Lua cannot find LuaRocks-installed modules on Linux

I installed the luarocks package on Linux Mint, and afterwards installed a couple of rocks such as sudo luarocks install telescope, but when running a script via lua script.lua, require cannot find the module. Meta: Doing this Q&A style, because…
Llamageddon
  • 3,306
  • 4
  • 25
  • 44
5
votes
3 answers

World of Warcraft (Lua) communication with Adafruit Gemma

I have an Adafruit (Gemma) / Arduino and a Neopixel LED ring that I would like to control from World of Warcraft in-game events. This part is soldered and working. Question: Is there any way to send communications between World of Warcraft and some…
DanAbdn
  • 7,151
  • 7
  • 27
  • 38
5
votes
1 answer

Lua ternary operator - multiple variables

Say I want to assign two values to two variables if a certain condition is true, and two different values if said condition is false. I would assume it would be done like this: a, b = 4 > 5 and 1, 2 or 3, 4 However this assigns a to be false, and b…
Tom
  • 6,601
  • 12
  • 40
  • 48
5
votes
2 answers

Syntax Change in lua 5.2 C api

I was trying to compile the example provided in the book Programming in Lua But only works for lua 5.1, What are the steps to do it on 5.2? This is the code I am using #include #include #include #include…
rocastocks
  • 153
  • 1
  • 10
5
votes
3 answers

Anaconda (Python) + Cmder (Clink) on Windows - Unify Dueling Custom Prompts

If you run Anaconda on windows, you have an activate.bat file which concludes with this line to put your current conda env on the prompt: set PROMPT=[%CONDA_DEFAULT_ENV%] $P$G If you run cmder on windows, there is a nice lua script to customize…
schodge
  • 891
  • 2
  • 16
  • 29
5
votes
1 answer

Lua - Insert or Delete String in txt file

Let's say I have a .txt file that contains a string. How can I delete some characters, or insert others between them? Example: .txt file contains "HelloWorld" and I want to insert a comma after "Hello" and a space after that. I only know how to…
user2276872
5
votes
1 answer

Untangling Lua & C code to make Lua dependency optional

I have written a little program in C to manage a bibliography database in SQLite3. So far, this is only a command line tool that allows importing and exporting BibTeX data. To make the export/import functionality more customizable (e.g. always…
1k5
  • 342
  • 6
  • 15
5
votes
3 answers

Differences between two tables in Lua

I have two tables in lua (In production, a has 18 elements and b has 8): local a = {1,2,3,4,5,6} local b = {3,5,7,8,9} I need to return 'a' omitting any common elements from 'b' -- {1,2,4,6} similar to the ruby command a-b (if a and b were…
tjrburgess
  • 757
  • 1
  • 8
  • 18
5
votes
2 answers

Send Get to website with lua

i'm having a trouble with lua. I need send a request to a website by GET and get the response from website. Atm all i have is this: local LuaSocket = require("socket") client = LuaSocket.connect("example.com", 80) client:send("GET…
Gmlyra
  • 109
  • 1
  • 1
  • 6
5
votes
2 answers

append to function lua

I have a function I want to add to dynamically as the program runs. Let's say I have function Foo: function foo() Function1() Function2() Function3() end and I want to change Foo() to: function foo() Function1() Function2() …
5
votes
2 answers

How do I call a script from a script in Redis?

I want to run many Lua scripts one after another, without allowing any commands to run in between. I also need to pass the result of the first script to the second one, etc. I've solved the problem temporarily by putting all my scripts in one file.…
kryo
  • 716
  • 1
  • 6
  • 24