lua

Lua library/code for parsing XML

I'm looking for a pure Lua library for parsing XML files. It doesn't have to be a validating parser, and it doesn't matter if it's DOM or SAX. The best resource I've found so far is the Lua Users wiki page on XML libraries (which seems to be down as I type this; check the Google Cache version for now). What experience have you had with ...

why do some tables in Lua display differently when print(sometable) is called on them?

I'm confused by behavior I'm seeing when I use luaxml to parse an xml string. The lua doc states that calling print() on a table variable as such: print(type(t)) print(t) will result in output like this: t2: table t2: table: 0095CB98 However, when I use luaxml as such: require "luaxml" s = "<a> <first> 1st </fi...

Lua stack issue

I can't really make a short yet descriptive title to explain my problem, so sorry for that. I'm calling a lua function called hook.Call(event, ...) from c++. It calls all functions added with hook.Add(event, unique_name, function) The problem is that when I call the print(...) function inside a hook it won't print what you'd expect it ...

MySQL database: lua or python

Under preferences(Menu)/general (Tab)/ Interactive GRT Shell Language: lua or python. What is the difference? I use MyQSL for database and involve mostly binary. ...

Storing values in a userdata object from lua

What I want to do is this: object.foo = "bar" print(object.foo) where "object" is a userdata. I've been googling for a while (using the keyword __newindex and lua_rawset) but I can't any examples that do what I want it to do. I want to do this in with the lua api in c++ ...

Access objects through Lua (iPhone SDK)

I'm trying to get to grips with how Lua works, and how it can be integrated into a project, like an Obj-C based iPhone game. I've got Lua's source integrated fine, and have managed to use a simple manager class to translate function calls written in a .lua file, to Obj-C methods in the project. I'm now a little stuck; I'm not sure how t...

Translation and rotation matrix

Hi, Does anyone have code to perform the matrix calculation for translation and rotation of a point I. 2D, please? Ive been looking all over the net and not found it in a form I can use. I'm coding in lua, but any other language would be fine. Many thanks, Matt. ...

Lua base converter

I need a base converter function for Lua. I need to convert from base 10 to base 2,3,4,5,6,7,8,9,10,11...36 how can i to this? ...

Can a function know whether it is running inside a coroutine?

Is there a way for a function to know if it is being run within a coroutine? For example I have a send_message() function that tries three times to send a message. Between each try it needs to wait one second. If this function is being called from within a coroutine, I'd like the send_message() function to do a coroutine.yield() as part...

Syncronization of access right between lighttpd and system

Hello! We are in the middle of designing a web server application which runs on an existing Linux system. We are using the lighttpd server, and have now ran into some security issues. For various reasons we have chosen Lua to develop our application. Since we have existing users that logs in to the machine using ssh, we would like the us...

Creating a C++ DLL loadable by Lua

I have a small app that uses Lua linked as dll (not static). I want to load my own c++-written dll via Lua using package.loadlib (libname, funcname). For this purpose I need to export a function that follows the Lua's lua_CFunction protocol. Clearly for that reason I have to incorporate lua.h into my project and use Lua's functions to pa...

Lua: garbage collection + userdata

Supposing the following situation: typedef struct rgb_t {float r,g,b} rbg_t; // a function for allocating the rgb struct rgb_t* rgb(r,g,b) { rgb_t* c = malloc(sizeof(rgb_t)); c->r=r; c->g=g; c->b=b; return c; } // expose rgb creation to lua int L_rgb (lua_State* L) { rgb_t** ud = (rgb_t **) lua_newuserdata(L, sizeof(rgb_t *)); ...

Lua: subtracting decimal numbers doesn't return correct precision

I am using Lua 5.1 print(10.08 - 10.07) Rather than printing 0.01, above prints 0.0099999999999998. Any idea how to get 0.01 form this subtraction? ...

Why won't applications in Program Files run using os.execute in lua?

I'm trying to run an executable using lua's os.execute() function. If I do something like the following it does not work: os.execute("C:\\Program Files\\Movie Maker\\moviemk.exe") However, if I put my lua file in the same path that moviemk.exe is in then it can call it. Any ideas why this may be? P.S. I'm using Windows XP SP3 ...

Integrating Lua to build my GameEntities in my Game Engine?

I really want to add Lua Scripting to my Game Engine. I am working with Lua and bound it to C++ using luabind, but I need help to design the way I will construct my Game Entities using Lua. Engine Information: Component Oriented, basically each GameEntity is a list of components that are updated in a delta T interval. Basically Game Sc...

Good free profiler that supports MingW32 please?

I asked in another thread, how to profile my stuff, and people gave me lots of good replies, except that when I tried to use several of free profilers, including AMD Codeanalyst for example, they only support Microsoft PDB format, and MingW is unable to generate those. So, what profiler can help me profile a multi-threaded application w...

How to improve workflow for creating a Lua-based Wireshark dissector

I've finally created a Dissector for my UDP protocol in Lua for Wireshark, but the work flow is just horrendous. It consists of editing my custom Lua file in my editor, then double-clicking my example capture file to launch Wireshark to see the changes. If there was an error, Wireshark informs me via dialogs or a red line in the Tree ana...

All fields list for packets in Wireshark:Lua

Im trying to get a list of all protocol fields for a packet. I tried all_field_infos, but it returns userdata and i couldnt figure the metatable to use to read it. Does wireshark pass a protocol tree to a tap ? ( we accept (tvb,pinfo,tree) for dissectors so i figured that it might ) Is there some Proto.fields sorta property which returns...

How can I limit lua possibilities (calling OS functions, modules, etc.)

I am using Lua as a script language inside my C application. It suits me well, but I can't understand how can I limit Lua not to call system functions, include other modules, etc. I want Lua to be able to call only functions that are allowed by me, because user can do all kind of bad things with full Lua + Lua modules power. ...

Lua Pattern for extracting/replacing value in / /

I have a string like "hello /world today/" I need to replace /world today/ with /MY NEW STRING/ Reading the manual I have found newString = string.match("hello /world today/","%b//") which I can use with gsub to replace, but I wondered is there also an elegant way to return just the text between the '/', I know I could just trim it, b...