Questions tagged [lua-5.1]

The v5.1 of the Lua scripting language.

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.

Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight scripting language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++).

Being an extension language, Lua has no notion of a "main" program: it only works embedded in a host client, called the embedding program or simply the host. This host program can invoke functions to execute a piece of Lua code, can write and read Lua variables, and can register C functions to be called by Lua code. Through the use of C functions, Lua can be augmented to cope with a wide range of different domains, thus creating customized programming languages sharing a syntactical framework. The Lua distribution includes a sample host program called lua, which uses the Lua library to offer a complete, stand-alone Lua interpreter.

Lua is free software, and is provided as usual with no guarantees, as stated in its license. The implementation described in this manual is available at Lua's official web site.

70 questions
2
votes
1 answer

Lua 5.1.5's Makefile Produces Errors for Me

If I try to run the Makefile that comes with the source of Lua 5.1.5, I get the following errors: gcc: error: #: No such file or directory gcc: error: DLL: No such file or directory gcc: error: needs: No such file or directory gcc: error: all: No…
NetherGranite
  • 1,940
  • 1
  • 14
  • 42
2
votes
1 answer

Program Just Repeats Prompt and then Ends no Matter what I Input (using Lua 5.1)

I am working with Lua 5.1. This is the program I am currently trying to run. print ("What is your name?") playerName = io.read() print ("Are you a boy or a girl?") playerGender = io.read() repeat if playerGender ~= "boy" or "girl" or "male" or…
2
votes
1 answer

"specified procedure could not be found" with Lua5.1 LuaSockets Win 64bit C++

I'm trying to make ZBS work in Windows, with both Lua 5.1 and luasockets compiled as 64bit C++ sources. I'm getting the following error: error loading module 'socket.core' from file 'socket\core.dll': The specified procedure could not be…
2
votes
1 answer

Writing a proper Lua 5.1 module with functions

I'm working with a program that has standard Lua 5.1 embedded and am trying to write a module I can call functions from but have had no avail. The current environment is quite picky, and if I make mistakes the scripts will break but will not get any…
Dan McCarthy
  • 23
  • 1
  • 5
2
votes
1 answer

Set different environment for same function in Lua 5.1

I would like to set different environments on the same function in Lua 5.1 (luajit): f = function() print(a) end b = setfenv(f, { a = 1, print = print }) c = setfenv(f, { a = 2, print = print }) I would like b() and c() to print different…
nehz
  • 2,172
  • 2
  • 23
  • 36
1
vote
0 answers

Lua io.popen freezing after a while of reading a log file

I'm attempting to constantly read and parse a log file (Minecraft log file) by using io.popen in tandem with Ubuntu's tail command so that I can send some messages upon certain events. Now, I have mostly everything working here, except one small…
1
vote
1 answer

Lua 5.1 discover function signature

I am trying to redocument the mod library for a game called 'harvest massive encounter' Their documentation that I was able to find: http://www.oxeyegames.com/wiki/index.php/Harvest_Library Redocumenting everything they have documented isn't an…
1
vote
1 answer

How to create a multi-dimensional Lua table with Lua C Api...?

Hi I want lua C api to create Lua table like table={['key1']={5,4,3,2},['key2']={1,0,1,1,0},['key3']={0,10,0,30,0,50}} thanks in-advance....
Abhi
  • 73
  • 8
1
vote
1 answer

Pre-process ... input - bad argument #2 to 'format' (no value)

I've got a scenario where I want to take input to a printf implementation and pre-process the arguments. My goal is to take the input, process the variable arguments (...) if necessary, and feed that into a string.format. The issue I'm encountering…
Ron O
  • 89
  • 7
1
vote
1 answer

Run a string as lua code to call a function with only the function name

I am making a dynamic callback table for a helper function that handles input events. I want to make a(testString) execute when functionTable[1](testString) executes or allow a way for it to be run directly from a string. functionTable =…
Grify Dev
  • 60
  • 1
  • 11
1
vote
3 answers

How can I use reflection (at runtime) in Lua?

I am trying to unit test code using Busted (which I did not write, nor am I allowed to refactor at this time for business reasons) in Lua, and there is no concept in this module of classes nor dependency injection. So, I'd like to replace some of…
Quinn Vissak
  • 131
  • 1
  • 8
1
vote
1 answer

Inspect function signature in Lua 5.1

In this answer, a method is provided for inspecting the signature of a Lua function. The answer notes that: This algorithm works with Lua 5.2. Older versions would be similar but not the same: What would the equivalent be in Lua 5.1?
AnandA777
  • 33
  • 5
1
vote
2 answers

How to remove a variable from child script environment in lua?

I have a script which I load with loadfile and then run it. Also I have the variable love in the scope of parent lua script and I want this variable be nil inside the child script enivornment but everything else untouched (print, math, pairs, all…
VP.
  • 15,509
  • 17
  • 91
  • 161
1
vote
1 answer

Lua sandbox to load many scripts

I want to make a wrapper which can load scripts regularly, but deleting the previous script data before loading another, the loaded scripts should have access to all global functions except some functions, like "print", also it should modify some…
Mostafa
  • 131
  • 1
  • 6
1
vote
2 answers

Handle special characters in lua file path (umlauts)

I have a small lua function to check if a file exists function file_exists( filePath ) local handler = io.open( filePath ) if handler then io.close( handler ) return true end return false end However, this will…
silent
  • 14,494
  • 4
  • 46
  • 86