lua

statically analysing Lua code for potential errors

I'm using a closed-source application that loads Lua scripts and allows some customization through modifying these scripts. Unfortunately that application is not very good at generating useful log output (all I get is 'script failed') if something goes wrong in one of the Lua scripts. I realize that dynamic languages are pretty much res...

Lua, C++, and poor man's subclassing

I'm lead dev for Bitfighter, and we're working with a mix of Lua and C++, using Lunar (a variant of Luna, available here) to bind them together. I know this environment does not have good support for object orientation and inheritance, but I'd like to find some way to at least partially work around these limitations. Here's what I ha...

Easiest way to parse a Lua datastructure in C# / .Net

Anyone know of an easy way to parse a Lua datastructure in C# or with any .Net library? This would be similar to JSON decoding, except for Lua instead of javascript. At this point it looks like I'll need to write my own, but hoping there's something already out there. ...

Embedding Rake in a C++ app? Or is there a Lake for LUA?

I've found a couple of questions about embedding Ruby in a C++ app. Almost all of the top-voted answers suggest using Lua instead. Given that a project I have in mind would be better served by the grammar already expressed in Rake (it's a rules engine), is there any easy way to embed Rake in a C++ app, or is there a Rake-like module for...

Pass variables between C++ and Lua via Swig

I'm working on a C++ project with a large number of classes (150+), each of which has anywhere from 10 to 300 fields or so. I would really like to be able to provide a scripting interface for testing purposes so that I can code callbacks that don't require any re-compilation. I'd like to do this in Lua since I'm more familiar with its C ...

how to get the closure in lua?

suppose i have a file name "test.lua" containing lines below: --[[ test.lua --]] local f = function() print"local function f in test.lua" end f_generate = function() local fun = loadstring(" f()") -- local env = getfenv(1) -- set(fun,env) return fun end f_generate()() --[[ end of test.lua--]] because loadstring doing its stuff...

luaopen_my_example undefined after compiling swig wrapper

I'm just now diving into SWIG as a means for creating Lua bindings, and I've hit a snag. I made my interface file and built a shared object file from it all without any problems. However, when I run Lua and try to require the shared object, I get the following: Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio require("my_example")...

Lua vs. Other scripting languages

I wonder why a lot of programmers claim that Lua is faster then any other scripting language? What did they do that is more efficient then other languages? Is there something completely different in their approach? What makes their code run faster then Python for example? ...

(SWIG / Lua) How to access the list of base / parent classes in swig_lua_class

I notice that in the generated SWIG wrappers for a given set of classes, SWIG keeps a list of C-string representations of all the parent classes from which that class inherits. (char ** base_names). I know there is a function swig_type(some_variable) that will return a string representation of a given variable's data type. Is there al...

Swig bindings for python/lua do not initialize member data properly

I'm trying to build a set of Lua bindings for a collection of C++ classes, but have been toying with Python to see if I get better results. In either language the bindings seem to work, however, when I initialize an instance of a class that contains members of other classes, those data members do not seem to be guaranteed to be initializ...

if i like Ruby a lot, is there a reason I should learn another language now, such as Lua or Erlang?

if i like Ruby a lot, is there a reason I should learn another language now, such as Lua or Erlang? ...

Lua on iPhone?

I am trying to use Lua on the iphone. On Mac OSX, in a normal Cocoa application (not iPhone), I used the following code: lua_State* l; l = lua_open(); luaL_openlibs(l); luaL_loadstring(l, "print(\"hi from LUA\");"); lua_pcall(l, 0, 0, 0); I downloaded Lua 5.1.4 from lua.org/ftp and I compiled it for Mac OSX. In the Xcode project, I h...

Example usage where Lua fits much better than C/C++

I'm currently embedding Lua and using it as a glorified intelligent config file. However, I think I'm missing something since people rave about the uses of Lua. For example, I can easily explain why you might use shell scripting instead of C by showing this example (admittedly , boost regexp is overkill): #include <dirent.h> #include ...

Basic assignment of swig wrapped variables fails

I created a lua module with a very large number of wrapped C++ classes using swig. The wrappers are generated and compiled (with -Wall) without any issues. However, in a couple of places that I've found, I run into the following issue: basic assignment of member data fails. If I run: Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio...

What is the maximum value of a number in Lua?

There doesn't seem to be a clear answer to this in the documentation. I'm interested in incrementing a variable time that counts the seconds since the program started. If the maximum value can count far into the future, like 100 years, then I don't care about letting the variable increment forever. Otherwise I'm going to have to think o...

Lua / c++ problem handling named array entries

I'm trying to write some c++ classes for interfacing with LUA and I am confused about the following: In the following example: Wherigo.ZCommand returns a "Command" objects, also zcharacterFisherman.Commands is an array of Command objects: With the following LUA code, I understand it and it works by properly (luaL_getn returns 3 in the ...

Const double initialised from Lua

I have a global variable: const double myvar = 5.1; Now, I'm converting this to read these values from Lua. However, I can't simply do: const double myvar = lua_tonumber(L,1); Since main() must first execute to start the Lua intepreter etc., but if I declare myvar afterwards, it will not be global. Is there any way to do achieve ...

Is Lua development stagnated, or are there still new versions planned?

Hi there SO, I was looking into learning Lua because it has some interesting features (speed being one), and I noticed that there hasn't been a feature update since 2006. Has Lua development stopped? If it hasn't, where can I read about recent progress? Edit: All caps Lua is what happens when you post on SO at 3 AM. ...

Best way to omit Lua standard libraries?

What is the best way to remove or omit a Lua standard library package? For example remove the os library functions in a particular environment. The project in question is building Lua from the source files so I can edit the source, although I would rather do it through the API if possible. ...

What is the C interface to Lua for accessing a table's key/value pairs?

In Lua, using the C interface, given a table, how do I iterate through the table's key/value pairs? Also, if some table table members are added using arrays, do I need a separate loop to iterate through those as well or is there a single way to iterate though those members at the same time as the key/value pairs? ...