lua

Swig C++ Lua Pass class by reference

I don't know why I'm having a hard time with this. All I want to do is this: class foo { public: foo(){} ~foo(){} float a,b; }; class foo2 { public: foo2(){} foo2(const foo &f){*this = f;} ~foo2(){} void operator=(const foo& f){ x = f.a; y = f.b; } float x,y; }; /* Usage(...

Fastest path to Lua SHA256 RFC-2104 compliant HMAC signature?

I'm running Debian Linux, and for a Lua script I need to create a SHA256 checksum to authenticate requests to Amazon Web Services. They don't say for sure but it looks as if they may want a base64 encoding of the resulting SHA256 checksum. I'd be happy if someone had done a Lua binding. I'd be content if someone could help me figure o...

Most efficient way to determine if a Lua table is empty (contains no entries)?

What's the most efficient way to determine if a table is empty (that is, currently contains neither array-style values nor dict-style values)? Currently, I'm using next(): if not next(myTable) then -- Table is empty end Is there a more efficient way? Note: The # operator does not suffice here, as it only operates on the array-st...

Pseudorandom number generator for noise

I'm trying to make the Perlin noise algorithm described at http://freespace.virgin.net/hugo.elias/models/m_perlin.htm using Lua. However, it doesn't work properly since Lua doesn't support bitwise operators, which are necessary for the pseudorandom number function on that page. I tried messing around with randomseed() but everything I co...

Safely generating XML in Lua

I'm writing a Lua application that generates an Atom feed. Right now, I'm generating XML "by hand" -- writing strings to files. This doesn't seem like the best way, although it may be. I am getting nervous about having the escaping exactly right. Has anyone done anything like this in Lua before? Should I stick with generating "by hand...

Import functions from table as local functions in Lua

I want to achieve this (import functions from util table as local values): function blah () local x = util.x local y = util.y ... end without having to reference each function explicitly, e.g. something like: function blah() for name,f in util do ??? end end Unfortunately there is no local table that I could set the wa...

Attempt to index a nil value in a script

I'm trying to write a lua script to assist in modifying a game, and it keeps breaking on one particular line of one of my assistant libraries. odfWriter.lua: require 'loopsetup' require 'ioWriter' local open = {} odfWriter = class{ writer = false } odfWriter[open] = false function odfWriter:open(name) if not self[open] then ...

Turning off antialiasing in Löve2D

I'm using Löve2D for writing a small game. Löve2D is an open source game engine for Lua. The problem I'm encountering is that some antialias filter is automatically applied to your sprites when you draw it at non-integer positions. love.graphics.draw( sprite, x, y ) So when x or y is not round (for example, x=100.24), the sprite app...

Lua, what is Lua?

Hi all? I read something about Lua this day, and I was wondering what it was. I did a Google and Wikipedia (I understanded it until they begun talking about a C API) search bit I still don't understand it. Can someone explain me what Lua is and maybe even a tutorial for beginners? Thanks in advance! ...

Lua scripting implementation

Hello, I'm currently working on implementing Lua into one of the applications that I'm working on. Currently I'm just using the C api and registering functions using lua_register, but I'd like to be able to pass static and non static function pointers to certain class methods. I've found certain libraries on the net, but since I need...

Lua - merge tables?

I need to merge two tables, with the contents of the second overwriting contents in the first if a given item is in both. I looked but the standard libraries don't seem to offer this. Where can i get such a function? ...

Lua Wrapper for C#?

I am looking to embed Lua into my C# application and i thought there was a wrapper around the lua API for C#, but don't remember what it is. Can someone point me in it's direction? ...

Overhead of Mono Tasklet/Co-Routines

Hi, What are the main performance overheads (gc/stack copying...) of the new Mono Continuations/Tasklet framework? How does this overhead (coroutine performance / raw performance) compare to other frameworks such as Lua Coroutine and stackless python? In Mono 2.6 continuation/coroutines support will be added. I built a svn version and...

Getting the face of a cube.

I want to calculate which face on a cube has been clicked. I've got the mouse to 3D down, and I can draw things, in 3D, at the mouse's position. All I need to do now is calculate WHAT face of a cube is being touched. EG. I have a function, when I pass the size, position and mouse position to it, it returns the face. Top, bottom, left, ...

lua for windows

I'm trying to use "lua for windows" - SciTE Simply example such as Print("hello") I hit Alt + R (per tutorial instructions), everytime I do this I get: "Unable to debug program!" Anyone had this problem? ...

[Web Development] - Lua vs PHP/Python/JSP/etc...

I'm about to begin my next web development project and wanted to hear about the merits of Lua within the web-development space. How does Lua compare to PHP/Python/JSP/etc.. for web development? Any reason why Lua would be a poor choice for a web application language vs the others? ...

Casting between void * and a pointer to member function

Hello Stackoverflow, I'm currently using GCC 4.4, and I'm having quite the headache casting between void * and a pointer to member function. I'm trying to write an easy-to-use library for binding C++ objects to a Lua interpreter, like so: LuaObject<Foo> lobj = registerObject(L, "foo", fooObject); lobj.addField(L, "bar", &Foo::bar); ...

What's the easiest way to convert an SO data dump from HTML back to Markdown?

I've just got my hands on a Stackoverflow data dump, and I'm disappointed to see that the Body field of the posts is in HTML rather than Markdown. I suspect there's Markdown in the original database because that's what I see if I try to edit an answer. I want to recover Markdown from a large set of answers. I will be processing hundre...

Improved Perlin Noise module for Lua

I need Improved Perlin Noise in my Lua code. Are there any decent open-source Lua C modules available? Or is there any nice C library that I can write a wrapper for (perhaps with other noise functions)? I know that it is not hard to write one myself (reference code in Java is trivial to port), but I do not want to reinvent the wheel h...

Lua decimal sign?

I've used this in other languages, but lua seems to be lacking this rather useful function. Could one of you nice chappies provide me a lua function to get the sign of the number passed to it? ...