lua.js

November 16th, 2011

I’ve been toying with Lua a lot lately. Lua is in some ways, the ultimate scripting language. It’s simple, effective, and supports a wide range of environments. The only missing environment, in my opinion, is the web itself, so I wrote a tool to convert Lua to Javascript.

Time passed and I kept updating it and fixing bugs, eventually adding support for ActionScript, and finally rewriting the entire thing in Javascript itself. It’s still experimental at this point, but I’ve open-sourced the project and released it onto github.

Click here to check out lua.js.

4 Responses to “lua.js”

  1. Murph Says:

    Awesome project! I discovered it today and can’t wait to play around. I’m still learning Lua but it is more attractive to me every day. Thanks for open sourcing this.

  2. Dylan sale Says:

    Nice project! Is it possible to extend the lua vm with functions that call into javascript, similar to how you can add cfunctions to the c lua implementation?

  3. Max Says:

    Dylan: Yes. Lua functions are Javascript functions that return arrays. That’s it.

    Here’s how you might add your own.

    lua_tableset(lua_script, “someFunctionLua”, someFunctionJs);

  4. Phil Hassey Says:

    LuaJS is really neat! Got my Lua game working in the browser with it.

    Here’s a patch for your string:format method:

    – return [“[” + slice(arguments, 1).join(“, “) + “]” + arguments[0]];
    + return [vsprintf(formatstring,slice(arguments,1))]

    Here’s the vsprintf implementation:

    https://github.com/alexei/sprintf.js/tree/master/src

    Thanks!
    -Phil

Leave a Reply