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 to play with a function which return table in lua?

i am not able to handle table which is return by a function.can any one help me on this ? local grades = { Mary = "100", Teacher="100",'4','6'} print "Printing grades!" grades.joe = "10" grades_copy = grades for k, v in ipairs(grades) do -- print…
Bee..
  • 195
  • 1
  • 8
5
votes
3 answers

Lua table sort does not work

I have the below program code which tries to sort a given list. I have tried various options and it still doesn`t work. local List = {} List[143] = "143" List[145] = "145" List[120] = "120" List[178] = "178" …
user2951607
  • 61
  • 1
  • 3
5
votes
2 answers

Is possible to use yaml metadata blocks to extend pandoc syntax?

First a little bit of context: I'm writing an academical article on pandoc/yaml + Leo Editor. With this combination I can write in a really organic way. Leo Editor tree is used to organize the writing in a non-linear fashion, so I can see the main…
Offray
  • 505
  • 1
  • 4
  • 15
5
votes
2 answers

What type of data does string.byte return?

What type of data does string.byte return in this sample code: s = string.byte("hello", 1, 6) type(s) returns "number", but why then does print output 6 numbers and not 1?
AndrewShmig
  • 4,843
  • 6
  • 39
  • 68
5
votes
2 answers

Returning key of maximum or minimum number in a table

A simple Lua problem here: how to find the index, or key, of the minimum or maximum number in a given table. math.max/math.min only gives the actual max or min number, not the key.
Lucien S.
  • 5,123
  • 10
  • 52
  • 88
5
votes
1 answer

LUA_MULTRET not working as expected

This is almost a duplicate of this question; however, the answer suggested there doesn't fix my problem, and I'm not using the luaL_dostring() macro directly (though I am using the same pair of calls that it expands to). Given this program:…
evadeflow
  • 4,704
  • 38
  • 51
5
votes
2 answers

How to navigate with .lua to a directory above

I have something like this. /config.lua /client/init.lua How can I include the config.lua with include() or dofile()? Lg
nn3112337
  • 459
  • 6
  • 21
5
votes
2 answers

Lua: How to call error without stack trace

I'm using Lua to parse scripts written in some language (let's call it L) and create Lua-code that can be run by e.g. LuaJIT. But to simplify debugging for the users, I want to map the run time errors given by Lua/LuaJIT to the correct line in the…
MartinValen
  • 93
  • 1
  • 11
5
votes
2 answers

Corona, system.scheduleNotification not working properly

I'm trying to implement an app with a local notification system. The system should cancel some unnecessary notifications. System.scheduleNotification works fine (it creates notifications and they work fine) but it returns nil (It supposed to return…
Doğancan Arabacı
  • 3,934
  • 2
  • 17
  • 25
5
votes
1 answer

Report error at source of __newindex call rather than inside __newindex function

I have a metatable with the following __newindex function: __newindex = function(t, key, value) set_value(t.sprite_number, key, value) end This lets me allow users to set "properties" on my lua objects (there's a corresponding __index function,…
Alex
  • 3,429
  • 4
  • 36
  • 66
5
votes
1 answer

how to deal with this memory leak in lua?

My machine is mac mini(2011) osx10.7.4 first of all. I download the lua-5.2.2 from lua.org, unzip it, and $ make macosx $ make install then i run it $ lua Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio > The memory usage now is 816KB (from…
e39a562r
  • 75
  • 7
5
votes
4 answers

Linker errors using LuaJava on OSX 10.5

I'm having a bunch of problems getting this library to work on my OSX installation. In particular, I'd like to use it with a Java 1.6 VM but after I compile it up I get the following: java -cp "luajava-1.1.jar"…
Daniel
  • 23,365
  • 10
  • 36
  • 34
5
votes
2 answers

"interval is empty", Lua math.random isn't working for large numbers?

I didn't know if this is a bug in Lua itself or if I was doing something wrong. I couldn't find anything about it anywhere. I am using Lua for Windows (Lua 5.1.4): >return math.random(0, 1000000000) 1251258 This returns a random integer between 0…
Houshalter
  • 2,508
  • 1
  • 18
  • 20
5
votes
2 answers

create table from two input tables .output table's key will be from first input and values will be from second input table

I am having a table in which I am passing names: names = {'Sachin', 'Ponting', 'Dhoni'} and in other table I am passing country names: country = {"India", "Australia", "India"} I want output table like: out_table = {Sachin="India",…
Prashant Gaur
  • 9,540
  • 10
  • 49
  • 71
5
votes
0 answers

Configurable Lua formatter

We recently added some policies to out fairly large Lua project, which also includes some stricter style guidelines than we used to. The problem we are facing now is to convert the whole codebase to the new style guidelines, which is a lot of work.…
Xandaros
  • 645
  • 1
  • 6
  • 17
1 2 3
99
100