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

Getting input from the user in Lua

How can I get an input from user in Lua (like scanf in C)? For example, the program ask user his name, then he writes his name, then the program will output his name.
oiyio
  • 5,219
  • 4
  • 42
  • 54
17
votes
5 answers

Using Lua for web development?

What issues or gotchas will I run into if I develop web applications in Lua; is there anything I should be aware of before starting? Any experience with developing Lua web applications?
TimH
17
votes
2 answers

How do modern VMs handle memory allocation?

I'm working on a simple stack machine written in C, mostly for learning purposes. After using malloc/free for my memory operations, I thought it would be a good idea to read some memory allocation specific code from modern virtual machines. I…
sinan
  • 6,809
  • 6
  • 38
  • 67
16
votes
3 answers

Any good text editor - Android app - optimised for programmers?

Are there any good Android apps - text editors, optimised for programmers? I'm asking about an Android app which is an editor! I am not interested in editors running on a desktop/laptop computers for editing Android programs. Features I am looking…
piokuc
  • 25,594
  • 11
  • 72
  • 102
16
votes
1 answer

Lua Code "tester"

I'm looking for some good Lua code 'tester' online, where I could paste my code and run it to see if the code is ok itself and if its running fine, as expected. It CAN be online tools, but I didnt say that I not accept any Windows applications which…
Cyclone
  • 14,839
  • 23
  • 82
  • 114
16
votes
1 answer

Lua - if statement with two conditions on the same variable?

How can I set a lower and upper bound value for a variable in a if-statement in lua programming language? I need something like the pseudocode below. if ("100000" >= my_variable <= "80000") then do stuff... end I've tried different formats but…
Mateus
  • 2,640
  • 5
  • 44
  • 62
16
votes
2 answers

Building a simple bridge between objc and lua?

I have integrated Lua with my ObjC code (iphone game). The setup was pretty easy, but now, I have a little problem with the bridging. I have googled for results, etc... and it seems there isn't anything that could work without modifications. I mean,…
Notbad
  • 5,936
  • 12
  • 54
  • 100
16
votes
2 answers

Best tool(s) for decompiling Lua bytecode?

I am really having trouble finding a good working Lua bytecode decompiler. I'm trying to decompile some scripting files I found in a game but they appear to be compiled, yet don't seem impossible to decode. What's the best tool to decompile Lua…
Jonathan Prior
  • 6,114
  • 7
  • 29
  • 26
16
votes
1 answer

How to embed Lua inside Python?

This sounds like a weird question, so I'll explain circumstances surrounding first. Basically, I have a 3D game development kit, written in Python, that works excellently by itself. However, most of my users will be used to using Lua as a scripting…
DangerOnTheRanger
  • 456
  • 1
  • 3
  • 10
16
votes
2 answers

How to write this regular expression in Lua?

I need to write the Lua equivalent of the following regular expression (regex) \b[0-9]*.\b[0-9]*(?!]) for use with Lua's string.gmatch. Can this be done? For reference, the above expression matches both the integer and fractional part of a number…
Goles
  • 11,599
  • 22
  • 79
  • 140
16
votes
6 answers

What parts of C are most portable?

I recently read an interview with Lua co-creators Luiz H. de Figueredo and Roberto Ierusalimschy, where they discussed the design, and implementation of Lua. It was very intriguing to say the least. However, one part of the discussion brought…
Miguel
  • 1,966
  • 2
  • 18
  • 32
16
votes
3 answers

Getting UTC UNIX timestamp in Lua

An API returns a timestamp as UNIX timestamp at UTC and I would like to know if this timestamp was more than x seconds ago. As expected, this works fine with os.time() - x > timestamp in UTC, but blows up in other timezones. Unfortunately I can't…
Azsgy
  • 3,139
  • 2
  • 29
  • 40
16
votes
3 answers

How do coroutines in Python compare to those in Lua?

Support for coroutines in Lua is provided by functions in the coroutine table, primarily create, resume and yield. The developers describe these coroutines as stackful, first-class and asymmetric. Coroutines are also available in Python, either…
user200783
  • 13,722
  • 12
  • 69
  • 135
16
votes
4 answers

Python vs Lua for embedded scripting/text processing engine

For a project I'm currently working on, I'm looking to embed a scripting engine into my C++ code to allow for some extensibility down the line. The application will require a fair amount of text processing and the use of regular expressions within…
Wade Tandy
  • 4,026
  • 3
  • 23
  • 31
16
votes
6 answers

Torch - repeat tensor like numpy repeat

I am trying to repeat a tensor in torch in two ways. For example repeating the tensor {1,2,3,4} 3 times both ways to yield; {1,2,3,4,1,2,3,4,1,2,3,4} {1,1,1,2,2,2,3,3,3,4,4,4} There is a built in torch:repeatTensor function which will generate the…
mattdns
  • 894
  • 1
  • 11
  • 26