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

Cannot make gunplot on osx yosemite. Undefined symbols

I try to make gunplot 5.0.0 under osx yosemite(10.10.4), and it comes with errors: $ make /Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive Making all in config make[2]: Nothing to be done for `all'. Making all in m4 make[2]:…
bayinamy
  • 487
  • 4
  • 14
5
votes
2 answers

Visualize images in intermediate layers in torch (lua)

In the conv-nets model, I know how to visualize the filters, we can do itorch.image(model:get(1).weight) But how could I efficiently visualize the output images after the convolution? especially those images in the second or third layer in a deep…
James LT
  • 733
  • 2
  • 12
  • 23
5
votes
3 answers

Web technologies for an embedded server

I've recently started a new web development project for an embedded device and wanted to solicit some recommendations for technologies to use. The device will serve HTML pages which include AJAX code to retrieve data from a JSON server. We're…
okalex
  • 788
  • 5
  • 12
5
votes
2 answers

How to Integrate Lua with .Net

Requirement is user should be able to add Lua script in text box, and then I need to check user has added proper Lua script and if script is correct then I need to run that script. Can anyone suggest me some code? I tried following: using (Lua…
Urvi
  • 220
  • 1
  • 3
  • 11
5
votes
1 answer

Awesome wm setting size for the tasklist item

I'm coding a custom vertical wibox that contains my tasklist, I want it to look like this: but instead of being fixed height, the tasklist items just take up all the available space. Here's the result: Here's my code so far: function…
Ben
  • 3,989
  • 9
  • 48
  • 84
5
votes
1 answer

What are the differences between doFile and require in Lua

What are the differences between doFile and require in Lua, especially in Torch? When do you call one but not the other? When will one work but the other won't? (I'm using Lua 5.1, torch7).
lars
  • 1,976
  • 5
  • 33
  • 47
5
votes
4 answers

Change lua variable from C

I have a main program (in C) which needs to branch out into lua_thread(the main continues to run).This lua_thread calls a lua_script.lua. this lua_script contains a while loop. a lua variable controls this while loop.Currently this loop runs…
bislinux
  • 193
  • 2
  • 3
  • 12
5
votes
1 answer

Lua variable scoping with setfenv

I'm trying to use raw Lua files for configuration purposes, but don't want the config files polluting the global namespace. The problem I'm running into is that dofile always seems to execute in the real global environment, so external files just…
SJML
  • 340
  • 4
  • 14
5
votes
1 answer

2D Line reflection on a "mirror"

So I've been working at this on and off for a week, googling and all and I haven't found how to do this. I have a table of "rays" and a table of "lines", and I want the lines to act as mirrors and reflect a ray whenever the ray hits a line. Imagine…
Lucas Watson
  • 763
  • 1
  • 8
  • 26
5
votes
2 answers

Lua in pairs with same order as it's written

Is there any way to loop trough a table like the one below in the same order as it's written? local tbl = { ["hello"] = 1, [2] = 2, [50] = 3, ["bye"] = 4, [200] = 5 } What I mean is that when I use "in pairs" I'll get a…
Felix
  • 2,256
  • 2
  • 15
  • 35
5
votes
2 answers

Lua C++ Table Iteration

I am having a slight confusion of how lua_next really works. User defines a table: a={["a1"]=20,["a2"]=30} I want to print this table with a C++ code: inline int lua_print(lua_State* L) { wxString wxReturnStr=wxEmptyString; wxString…
macroland
  • 973
  • 9
  • 27
5
votes
1 answer

Run Lua script from Python

Suppose I have a Lua script that contains 2 functions. I would like to call each of these functions with some arguments from a Python script. I have seen tutorials on how to embed Lua code in Python and vice versa using Lunatic Python, however, my…
user2253546
  • 575
  • 1
  • 8
  • 18
5
votes
1 answer

does redis cluster support transactions ?

i'm a newbie for redis, i've just been using redis for couple of months. Currently i'm using 2.8.x stable version but i'm trying to use 3.0.0 to import redis cluster funtions. i'm using java jedis as client,and here is my problem:i found that the…
Kim
  • 5,045
  • 6
  • 38
  • 60
5
votes
1 answer

Erlang spawning large amounts of C processes

I've been looking into how I could embed languages (let's use Lua as an example) in Erlang. This of course isn't a new idea and there are many libraries out there that can do this. However I was wondering if it was possible to start a Genserver with…
user967965
5
votes
1 answer

Fast way to initialize a tensor in torch7

I need to initialize a 3D tensor with an index-dependent function in torch7, i.e. func = function(i,j,k) --i, j is the index of an element in the tensor return i*j*k --do operations within func which're dependent of i, j end then I…
MarsPlus
  • 321
  • 4
  • 7