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
1 answer

How can I create a table in Lua, then add values from the C API?

Here's what I have so far... It creates global table called "mod", but I can't seem to add indexes to the table... lua_newtable(L); lua_setglobal(L,"mod");
Sam H
  • 956
  • 4
  • 16
  • 24
5
votes
2 answers

LUA: Find and return string in double quotes

I try to find a string in a HTML-Body, the string looks like var version="1,1,0,0"; and i only want to extract the content between the double quotes. I have tried it with local version = string.match(response.body, ".version.") return version
loxi2017
  • 51
  • 1
  • 6
5
votes
2 answers

Lua : copying a table efficiently (deep copy)

I try to make efficiently a copy of a lua table. I have written the following function copyTable() that works well (see below). But I imagined I could have something more efficient using the "passing by value" mechanism of the functions. I made a…
5
votes
0 answers

Can I get popups on mouseover for inline documentation in Sublime Text?

I'm used to Android Studio, which has these awesome popups when you hover your cursor over a function (or anything else), which shows you a description, parameters, etc.. Now I'm using Sublime Text 3 for Lua programming, and I would like to have a…
Timmiej93
  • 1,328
  • 1
  • 16
  • 35
5
votes
3 answers

How would I make a C-function that I can call from Lua?

I would like to know how to make a C-function and be able to tell Lua about it, then call it from Lua. I have all the Lua Libraries installed on my Mac OSX 10.4 computer.
SHa
  • 51
  • 1
  • 2
5
votes
2 answers

Date formatting in Lua

I am retrieving a date from a database in the following format: vardate = '01/20/2017 09:20:35' - mm/dd/yyyy hh:mm:ss I want to convert it to the format dd-mm-yyyy hh:mm:ss Can I get some guidance on how I could get the format I want?
edcoder
  • 503
  • 1
  • 5
  • 19
5
votes
2 answers

Multiple HMSET to Redis with Lua script

Due to performance, I need to minimize the number of hops to Redis. I am calling HMSET multiple times from C++ code and I am investigating if it is possible to change this by using Lua script and set multiple Redis hash keys with one call to…
georgeliatsos
  • 1,168
  • 3
  • 15
  • 34
5
votes
2 answers

Best way for Lua script to call a C shared lib?

I come from more of a Python and CTYPES background...and am trying to work out the best way to call a standard C shared lib from Lua script. I have heard of "Alien" (http://alien.luaforge.net/), but am not sure how current it is? Meaning it is…
Lynton Grice
  • 1,435
  • 3
  • 29
  • 45
5
votes
2 answers

Cannot link a minimal Lua program

I have the following trivial Lua program which I copied from the book Programming In Lua #include #include #include #include int main (void) { char buff[256]; int error; lua_State *L =…
JohnP
  • 677
  • 1
  • 9
  • 18
5
votes
2 answers

WoW Lua - Get Data from URL (Vanilla)

In a World of Warcraft Vanilla Lua Addon Development, how can I issue an HTTP call to receive data back? If not, how can I get data from a web source into the game while playing? I have a feeling the answer is tragically short, but would like the…
Suamere
  • 5,691
  • 2
  • 44
  • 58
5
votes
1 answer

Is there a table that can be used to access local variables in Lua?

Just like how we can do this: a = 3 print(_G['a']) -- 3 I want to be able to do something like this: local a = 3 print(_L['a']) -- 3 I basically want to be able to access local variables using their names as strings. Is there a table that can do…
Kyle Delaney
  • 11,616
  • 6
  • 39
  • 66
5
votes
1 answer

Can you Yield and Resume Luajit coroutines from anywhere in C?

I am trying to come up with a solution for yielding a Luajit coroutine from a C function that immediately creates a tasklet to be processed on another OS thread. According to various Lua documentations, and things began to heavily contradict each…
5
votes
3 answers

Order of operations (== vs. not)

Does anyone know why "boolean not" has higher precedence than == in order of operations for most programming languages? In mathematical logic/model theory, isn't it the other way around? I recently wrote the following in Lua: if not 1 == 2 then …
Mike
  • 51
  • 1
5
votes
2 answers

Read file line by line into array

sorry i am still learning about lua. could you correct me, why the data from file wont read line by line ? this is my example data in file points.txt : lexxo:30:1 rey:40:2 lion:40:2 prince:50:3 royal:50:3 so when i got from above is the 2d…
Han
  • 93
  • 1
  • 9
5
votes
3 answers

Creating new classes/members at run-time in scripting languages used in C++

I've been working on this problem off and on for a few months, and now wanted to really come up with a proper solution that will handle the case of creating new user-defined classes (and instances of those classes) with member functions/properties…
Mike Weir
  • 3,094
  • 1
  • 30
  • 46