lua

Lua and Alien structures

I'm trying to redefine this C structure to Lua with alien 0.50 module however I have a two arrays of char at the end. Both szLibraryPath and szLibraryName are originally defined as char szLibraryPath[MAX_PATH] in C. Can this be done with alien? LIBRARY_ITEM_DATA = alien.defstruct{ { "hFile", "long" }, { "BaseOfDll", "long" }, { "...

Lua vs. XML for data storage

Many of us have been indoctrinated in using XML for storing data. It's benefits and drawbacks are generally known, and I surely don't want to discuss them here. However in the project I'm writing in C++, I'm also using Lua. I've been very surprised how well Lua can be used to store and handle data. Yet, this aspect of Lua is less recogni...

Tracking Lua tables in C

I have C++ objects and I have Lua objects/tables. (Also have SWIG C++ bindings.) What I need to be able to do is associate the two objects so that if I do say CObject* o1 = getObject(); o1->Update(); it will do the equivalent Lua: myluatable1.Update(); So far I can imagine that CObject::Update would have the following code: void ...

How to make plugable factory work with lua ?

class data is like this: struct Base_data { public: Base_data(){ protocolname = "Base"; } string protocolname; }; class HttpData : public Base_data { public: HttpData(){ protocolname = "Http"; } }; class Professor: class Base_Professor { public: void Process(Base_data if(it == ListProf...

Lua for configuration over XML/Yaml/INI in .NET?

I have used XML, INI and yaml files for configuration in the Python as well as in .NET C# application. I have recently studied the lua language and tried its implementation in .NET platform. I find Lua for configuration seems to be more clean and readable. Moreover it does provide the scripting ability. Since I heard that Lua source b...

Linker errors using LuaJava on OSX 10.5

Hi, I'm having a bunch of problems getting this library to work on my OSX installation. In particular, I'd like to use it with a Java 1.6 VM but after I compile it up I get the following: java -cp "luajava-1.1.jar" org.keplerproject.luajava.Console Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/dharabor/src/luajava-...

"Extend" the "string" table - how to do it? Is it even a good idea?

I am developing a Lua library in which I needed to uppercase the first letter of a given string. Hence I created the following function: local capitalize = function(s) return string.gsub (s, "(%w)([%w]*)", function (first, rest) return string.upper(first) .. rest end, 1 ) end This initially was an "internal" ...

Associatively sorting a table by value in Lua

I have a key => value table I'd like to sort in Lua. The keys are all integers, but aren't consecutive (and have meaning). Lua's only sort function appears to be table.sort, which treats tables as simple arrays, discarding the original keys and their association with particular items. Instead, I'd essentially like to be able to use PH...

Has anyone used Lua to build a web application?

I come from a Java and PHP background to build web applications. Has anyone used Lua before to build a web applications? Question: If so, what are the pro's & con's of using Lua versus PHP or Java for a web application? (e.g. web server support, performance, code maintenance, etc). ...

Lua crashes when programs are compiled

I'm working on a very, very simple Lua program, trying to teach myself the language. Here's the three line program: file = io.open("hello.txt", "w") file:write("Hello, World.\n") io.close(file) When I use the program with Lua as a script, it works fine. When I compile the program, it works. However, when I run the compiled program,...

Retrieving Application Data folder from Lua

Hi, I have trouble getting Application Data in Lua. I can't even find how to do it, here on SO or anywhere else. Thanks for help. ...

how to judge of the trade-off of lua closure and lua coroutine?(when both of them can perform the same task)

ps:let alone the code complexity of closure implementation of the same task. ...

Getting table entry index

I can't get table entry index. I need it to remove an item from table. I use table.insert to add entries to table. Another question: why Lua doesn't have "overload" to function table.remove so one can remove item by associative index? ...

Can't sort table with associative indexes

Hi, why I can't use table.sort to sort tables with associative indexes? ...

why not a lua implementation of google's protocol buffers? is there already any better solution exist for lua?

why not a lua implementation of google's protocol buffers? is there already any better solution exist for lua? ...

Is Lua interesting, from a programming language design perspective?

Lua occupies a good place in the space of languages that can be embedded. Is this a result of interesting new ideas the implementors had, or is it a result of good execution of well-established ideas? Comparison of properties and features of Lua to other PLs are particularly appropriate. ...

Mac OS X. No such file or directory for Lua framework.

I have Cocoa project which uses Lua.framework. In the header file I try to include some .h files from this framework: ... #include <lua.h> #include <lauxlib.h> #include <lualib.h> ... And when I compile the source file I get this error: error: lua.h: No such file or directory error: lauxlib.h: No such file or directory error: lualib...

Treating nils in sort function

Hello, I don't know how to handle nils my sort function gets. When I have this checking in it, table.sort crashes after some calls. if a == nil then return false elseif b == nil then return true end With this error:invalid order function for sorting. But according to the documenatiton, sort function should return false, if a ...

lua_pop vs lua_remove

currently I'm building my own script VM manager class in C++, I have no problems with any of the lua & lua C or C++ stuff, but the one section that confuses me is: when to use lua_pop and when to use lua_remove. From what I understand, lua_pop is to remove multiple values(on the stack) from the top down, eliminating data that is no lon...

Which programming languages support hot code swapping and/or sandboxing?

Hello, I would like to write a web based MMO game that will allow users to write AI and run it as part of the game. I plan to use Html5 for graphics and want this to be web based so it can be accessed from smartphones. I need to find a programming language that will support sandboxing, concurrency, hot code swapping, and a large librar...