Building a HTML runtime for Codea

It would be nice with a HTML runtime for Codea, so that you could publish your small prototypes on the web. I just made a minimal attempt of it. Tried using lua.js. Another solution would be to use Lua compiled with Emscripten instead, don’t know how full featured lua.js is.

Anyway, here is the silly example. Someone with a lot of free time could probably make a runtime with for example three.js for mesh and shader support. :slight_smile:

Took me long enough to figure out where you got the “lua+parser.js” file from… LÖVE WebPlayer. The web player comes with shaders and many libraries similar to Codea’s, so I’ll look into making a fully-functional HTML5 Codea run time.

You guys are awesome! I am so amazed at the power and possibilities of Codea.

.@tnlogy your example does not work on safari-ipad1 or…?

No. I got it from the library lua.js as I describe above. But I guess LÖve uses the same library since it is a quite ambitious implementation of lua in javascript. Good luck with the implementation, will be interesting to see the result! :slight_smile:

Oops, no, I’ve just tried it on Chrome actually, so there is probably some bug with it on iOS. Use Codea instead :wink:

Here is the github project for lua.js if you havent found it already

I see that Löve web player is based on webgl, so it wont work on iOS safari or android, but I guess the main focus would be desktop platforms, which is nice. If using three.js as a base you could use the canvasrenderer when webgl is not available, but might be more work when that web player already integrated box2d and other libraries.

@tnlogy - Yes, that is an issue I had noticed. First if all, Apple doesn’t allow it on the app store, but you can enable WebGL in a webview. Look here if you are looking for more info: That being said, iOS is not an issue because you can natively export your code.
As for Android, I’m still looking for a solution… FireFox and Chrome use WebGL in android… So I know it’s possible. The Sony Ericsson natively supports WebGL, but that’s the only phone that does.
Some things I might experiment with is using this library: Another possibility would be to simulate the Chrome webview with enabled WebGL by downloading Chrome Canary for Android here:
As for publishing to desktops, most desktops now and days support WebGL, so you don’t need to worry about that.
If you have any ideas, post it below.

Yes. WebGL sounds like a great solution for desktop.

For Android I think it would be too slow to use javascript to interpret lua. The suggestion I’ve written about earlier was to use the Moai runtime, whih is in Lua. But that would also require a lot of work to write the Codea API for it. I wrote a proof-of-concept earlier:

But it would be nice to be able to target many platforms. But I think to make Lua code run in the browser would be great, easier to share the code then :slight_smile:

@tnlogy - To your surprise, at least on this tablet, WebGL runs just about as fast as my Mom’s 2010 MacBook Air with 8GB of RAM. Look here for a demonstration of some three.js apps on an android:

Nice! It was slower when I tried it on a xoom, but that was a while ago on firefox, which was the only supporting webgl back then. As long as the lua runtime isn’t too slow it seems like a nice solution also for android then. :slight_smile: