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 can find the missing bracket in this code?

When I run the code it tells me there's an error which is ')' expected near '=': function restartLvl() for i = 1, #balloonTexts do display.remove(balloonTexts[i]) print ("restart level") end score.text = '0' …
user3305142
  • 227
  • 1
  • 2
  • 9
5
votes
1 answer

Lua code, square in game

I have a problem, the square and the circle you can see in the picture. Do not know how to delete this, can anyone help me for do not show it? The example of code is this: supermanSpriteSheet = sprite.newSpriteSheet("superman.png", 100,…
Chete
  • 51
  • 1
5
votes
4 answers

Sum of the digits of an integer in lua

I saw a question like this relating to Java and C, but I am using LUA. The answers might have applied to me, but I wasn't understanding them. Could someone please tell me how I would get the sum of the individual digits of an Integer. For Example. a…
Mikelong1994
  • 77
  • 2
  • 7
5
votes
1 answer

attempt to call method 'translet' (a nil value) in corona

For this function fallingCoins(), I'm getting backward moving coins in my code and I need to hide these coins when anchor touches the coins. function fallingCoins() local myPlayer = display.newCircle( math.random(20,_W+20), -25, math.random(10,10) …
VenkatSoma
  • 93
  • 6
5
votes
2 answers

Lua: Skip variable declaration

I am trying to "Skip" a variable, by either never declaring it or just having it garbage collected immediately, but I don't know if it's possible. Example: function TestFunc() return 1, 2 end function SecondFunction() local nodeclare, var =…
5
votes
1 answer

Lua 2D array error

So I am fairly new to Lua, and in other languages I have been able to create a 2D array of variables and simply index through the array in order to create a tiled map. Whenever I try this in lua I get an error (specifically an error stating that I…
devCorner
  • 193
  • 4
  • 15
5
votes
1 answer

Registering a closure with Lua

Instead of using the lua_CFunction signature for writing methods to be called from Lua, I'd like to use my own function signature that simplifies the export process. void foo(call_t *call) { int a; char *b; char *c; table_t *d; …
jmegaffin
  • 1,162
  • 11
  • 22
5
votes
1 answer

Corona SDK Vector Circles Antialiasing - does it work?

I have searched a ton and even upgraded to graphics 2.0 since I read that antialiasing of vector shapes was now working in Corona. That being said, everything is still either pixelated (in the simulator and my phone) or polygonal (on my Nexus 7). I…
jon
  • 170
  • 1
  • 13
5
votes
2 answers

How to end a looping coroutine in Lua?

I'm currently working on a game using Roblox (which uses Lua). It is a basically made up of several minigames. At the beginning of each round, all the players in game are put in a table and teleported to an area. That is where the coroutine comes…
user3314993
  • 287
  • 1
  • 4
  • 11
5
votes
2 answers

How free up memory allocated by lua_newuserdata with delete operator?

How can I free memory allocated by lua_newuserdata? I have a class called Foo, and this class has a constructor and desstructor, and I need execute both, but I don't know how to use the C++ operator delete, because I didn't use new to allocate…
user3312225
  • 53
  • 1
  • 4
5
votes
1 answer

Detect file opening error on Lua

I'm using Lua on iOS and I'm having problems to open a file with io.open("filename.txt","w"), I know that I'm receiving nil, but is there any way to detect the failure reason and try to solve it according to that? something like errno of C?
5
votes
1 answer

How to find which version of Lua do I use?

I develop app by using Lua Glider 2 + Corona SDK latest release. How can I find which version of Lua do it use? Thank you.
Anatoly
  • 5,056
  • 9
  • 62
  • 136
5
votes
1 answer

Get a 'clear' error message in Lua

I am using the error function in quite a few of my functions and would like to propagate the error messages to the user. However, I obviously don't want to include information about where the error occured exactly; this information should only go to…
Henrik Ilgen
  • 1,879
  • 1
  • 17
  • 35
5
votes
2 answers

Making sense of OOP in Lua

I do most of my programming in Python, and I use OOP practices for most of my projects. I recently started taking a look at the Love2D game library and engine. I managed to get some things configured, and then thought about making a GameObject…
5
votes
3 answers

How do I place an object on the other side of the screen

I'm writing a program for a mobile app development class that I am taking. The app involves me placing 2 buttons on the screen. I know that when I put /2 it places it in the middle, and when I put /3 it places the button a third of the way from the…
1 2 3
99
100