Questions tagged [lua]

Lua is a powerful, fast, lightweight, embeddable scripting language.

Lua is widely used as a scripting language by game programmers, perhaps owing to how easy it is to embed, its fast execution, and its short learning curve.

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 ANSI C, but a list of several other implementations can be found on the Lua Users Wiki page on Lua Implementations.

The current official version of Lua is 5.2. The previous version (5.1) is available in the version history on the official site.

Free Lua Programming Guide


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.

256 questions
38
votes
5 answers

What are the pros and cons of incorporating Lua into a C++ game?

I have a C++ game programming book and it has a Lua section in it. I've started to read the Lua section, and it sounds interesting, but I can't determine the pros and cons of using Lua in my C++ game. The only benefit I can currently think of is…
Ryan
  • 887
  • 2
  • 8
  • 10
10
votes
2 answers

How to use LuaJIT the same that Lua in a C++ program?

I'm using Lua in my C++ program, as an library. But I read that LuaJIT is a better implementation. Is it posible to replace with LuaJIT with little change? How?
Zhen
  • 1,316
  • 1
  • 13
  • 30
6
votes
2 answers

Lightweight lua objects vs. inheritance

Although I did this a couple of times from scratch, still no solution really fits. I'm using lua for scripting in my games. Lua holds the "prototypes" of the game elements, that are copied to each entity on it's creation. A prototype represents a…
4
votes
4 answers

Obscuring stored info in a flat-text file

I have an idea for an addon for World of Warcraft which would basically be a minigame within the game itself. Eventually, I'd like to have players be able to compete against each other directly. The game would have some RPG-like elements,…
Asmor
  • 440
  • 3
  • 11
4
votes
3 answers

Protobuf vs Lua for custom file format

I'm defining a custom/simple file format for loading textures in my game. I narrowed my choice of file formats to two options: Lua protobuf I chose Lua, because my game is already using Lua, I wouldn't need to add protobufs to the build. …
deft_code
  • 7,602
  • 5
  • 37
  • 54
3
votes
1 answer

Is it possible to develop a game with Lua/Löve and have the source code compiled?

I've been looking at Lua and Löve for developing simple 2D games. But since Lua is interpreted and I know it can be compiled to some point, but how secure is that to decompiling. Or is there a better way to distribute the game?
Ólafur Waage
  • 3,643
  • 1
  • 29
  • 32
2
votes
2 answers

Viewport like Angry Bird in Corona

Not sure if that's the right name for it, but I'm looking for a way to implement zooming in my game. Essentially the game should zoom in on my character during the moving and shooting phase (its like Worms), but zoom out when the character has shot…
Cleverbird
  • 31
  • 3
2
votes
1 answer

How can I link to callback functions in Lua such that the callbacks will be updated when the scripts are reloaded?

I'm implementing Lua scripting in my game using LuaBind, and one of the things I'm not clear on is the logistics of reloading the scripts live ingame. Currently, using the LuaBind C++ class luabind::object, I save references to Lua callbacks…
Raptormeat
  • 776
  • 2
  • 6
  • 15
1
vote
2 answers

How to run multiple Lua scripts within the same lua state without conflict

I've been working with Lua for sometime and there is a problem that I could never solve it. First, I'm using a single lua state to have a connection between my scripts so they could transfer data via global table _G. My scripts have a template like…
MahanGM
  • 367
  • 4
  • 22
1
vote
0 answers

Determine required camera pitch/yaw change based on mouse movement and roll?

I'm sure this is going to be a pretty simple answer but I can't quite figure it out on my own. Each frame, I'm getting the mouse's distance from the center of the screen (left/up is positive) and using it to change the camera's pitch and yaw. Then,…
1
vote
0 answers

Verb+Noun Parsers and Old School Visual Novels

Hi I'm working on a simple old school visual novel engine in Lua. Basically I have most of the code set up besides one important feature. The Text Parser. Lets get into how words are generally structured. In the screenshot I input the command "my…
user38943
  • 19
  • 2
1
vote
0 answers

How to get started in game development with Lua without LOVE or any game engine

Recently, I've been wanting to get into Lua, and I just started to. I was wondering if it is possible to make a game, without the LOVE engine, like are there any built-in libraries I can use or external libraries? How would I install these…
Pale_Gray
  • 19
  • 6
1
vote
0 answers

How to include moai in lua code for running it using luajit?

I'm running moai from ubuntu for some simulation purposes. I have a lua script that is executed using luaJIT. Now I want to run a simulation written based on moai from within this script. As of now, i can run the simulation like this : moai…
Srinivas K
  • 111
  • 2
0
votes
1 answer

Why is mission planner not reading my Lua script?

Whenever I try to run my Lua script, right after the first function, be it defining a parameter, mission planner (ground control station of ardupilot), display an error message saying unexpected token. function pr() local altitude =…
0
votes
1 answer

Rotating an object in a circular path (using time)

I want to move an object in a circular path but I want it to complete its movement in that circle when the time ends. I tried doing this: p.tmy = p.tmy + p.duration/p.radius p.x0 = p.radius * math.cos(p.tmy + 0.025) p.x1 = p.x0 * math.cos(p.tmy) - …
Achaibo
  • 3
  • 1
1
2