lua

What's the best way to distribute Lua and libraries?

I'm looking at moving a program that currently embeds a Python interpreter to use Lua. With Python it's fairly easy to use modulefinder, compileall, and zipfile to make a nice tidy zip containing all the external libraries used. Does Lua have the ability to bundle up its libraries like that, or is there some better best practice for di...

Embedding Lua into a C# Windows form, and using LuaInterface to debug Lua.

I have a windows form which a richTextBox and a button, and another form for debugging Lua. I was wondering how I can use LuaInterface to debug the Lua code that is in the richTextBox and print the output to the next form. I am using Microsoft Visual C# 2008 Express Edition for this. I have Lua51.dll and LuaInterface.dll in the .exe di...

Correct software-engineering approach to make Lua bindings to my C++ classes ?

I'm trying to figure out the best way to register my C++ Classes constructors with Lua (from a software design perspective, not a coding perspective) How shall I do this ? My Ideas: 1) Make some kind of "init Lua bindings" file which binds each of the C++ constructors that I want to have available in Lua ? (problem: this file would ...

Destructors in Lua?

Is it possible to get destructors in Lua w/o using userdata? http://www.lua.org/notes/ltn006.html looks promising (in fact exactly what I want); except it's a path for Lua 4.0. Basically, I want a way to have a function called when a table is collected. Thanks! ...

Calling a Lua script from C: errors

I'm new at Lua and writing bindings in general. At the moment I'm just trying to compile the first example found here (with the functions updated to Lua 5.1). #include <stdio.h> #include "lua.h" #include "lualib.h" #include "lauxlib.h" /* the Lua interpreter */ lua_State* L; int main ( int argc, char *argv[] ) { /* initialize Lua...

lua - get the list of parameter names of a function, from outside the function

I'm generating some (non-html) documentation for a Lua library that I developed. I will generate the documentation by hand, but I'd appreciate some kind of automation if possible (i.e. generating skeletons for each function so I can fill them in) I'd like to know if there's a way for lua to know the names of the parameters that a functi...

Use Lua To Open .chm At Defined Index Page

I wish to open a specific page within a .chm file from lua, but can not find any resources that would instruct me as to how how this task may be accomplished. If someone could provide some code that would open an index page named "Test2" in a file named "TestFile.chm" from lua I would greatly appreciate it. Thank you very much :) ...

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 throw all their declarations into _G. Here's an example main file, with comments indicat...

How do I convert a int to an array of byte's and then back?

I need to send an integer through a NetworkStream. The problem is that I only can send bytes. Thats why I need to split the integer in four byte's and send those and at the other end convert it back to a int. For now I need this only in C#. But for the final project I will need to convert the four bytes to an int in Lua. [EDIT] How abo...

lua - metadata for documentation

I've read a comment from Norman Ramsey about using metadata for generating documentation in lua. I'm attempting to generate documentation from my lib, and I'd rather not use luadoc if possible. I'd like to know more about this "metadata-oriented" method for generating documentation - methodology, examples, or programs used. Other answ...

Lua C api : How to load lua files defined as modules ?

Hi, I have the following lua script : module("modoo",package.seeall) foo=1 bar={12,34} Which works fine using the cli, such as : > dofile "mod_modoo.lua" > =modoo.foo 1 > =modoo table: 0x86ce058 As far as I understood, it works like a table, but whenever I try loading it as a table, a nil value is pushed onto the stack. Every othe...

Does Lua make use of 64-bit integers?

Does Lua make use of 64-bit integers? How do I use it? ...

Why does Lua report that lua_pushlstring is undefined?

I managed to compile Lua 5.1.4 for Palm webOS and now I'm trying to write an extension to use webOS' services from Lua. However, when I try to load my library, Lua reports: undefined symbol: lua_pushlstring Here's my code: #define LUA_LIB #include "lua.h" #include "lauxlib.h" static int hellopalm(lua_State *L) { lua_pushliteral(...

There is a type named thread in lua. Does anyone know something of this?

I was reading the lua manual (looking for something) and I found out that there is a type named thread in lua. Of wath I read it represents independent threads of execution and it is used to implement coroutines. Here is the link to the place I read it. http://www.lua.org/manual/5.1/manual.html#2.2 How do I use these threads? Are there...

Why are there only 4 fields in this lua table? Shouldn't there be 7?

Why are there only 4 fields in this lua table? Shouldn't there be 7? polyline = {color="blue", thickness=2, npoints=4, {x=0, y=0}, {x=10, y=0}, {x=-10, y=1}, {x=0, y=1} } print(table.maxn(polyline)) -- returns 4. Why? print(polyline[2].x) -- ...

How do I write a c++ dictionary to a Lua table?

I have some C++ code that interacts with some Lua code. Basically, I want to be able to get some results (in the form of a dictionary a.k.a a collection of items) from a query message and then push them out to Lua as a table so that I can easily access all the results from Lua by using the dictionary. Right now, I just get one specific ...

Creating a Lua Table from a const char **

I have a const char ** which is going to be of varying lengths, but I want to create a lua array from the const char **. My const char ** is something like this arg[0]="Red" arg[1]="Purple" arg[2]="Yellow" I need to convert this array to a global table in Lua, but I'm not sure about how to go about this as I'm not very good at manipu...

Lua function return string with C++

Is it possible to add a function to Lua via C++ that returns a string? -edit- Ok, this code wont work. Any help? int flua_getinput(lua_State *L){ if(lua_isstring(L,1)){ cout << lua_tostring(L,1); cin >> input; cout << "\n"; lua_pushstring(L,input); }else{ cin >> input; cout << "\n"...

Lua metamethods not being called

I'm kinda new to Lua (not really done much with it yet) and I'm trying to wrap my mind around metatables. I have had them working before but now (after a number of months) I have encountered something really weird. What should this script print when run? __mt = {} __mt.__index = function(table, key) print("In __index") return ...

Web technologies for an embedded server

Hey everyone, 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 tentatively using Cherokee as the web server, though we're not tied to it. Curre...