2

I want to allow users to execute Lua through my webpage (use the Lua to manipulate elements on the page). How would I perform this? Is this possible?

What language would be required to do all of this? Can I do this with only HTML and JavaScript? Do I need to use a language such as ASP or PHP?

Thanks if you can!

Freesnöw
  • 30,619
  • 30
  • 89
  • 138
  • Apache httpd 2.3+ will has [mod_lua](http://httpd.apache.org/docs/trunk/mod/mod_lua.html) on board. – ulrichb May 02 '11 at 21:58
  • The responses you're getting support a broad range of Lua solutions, it might help if you were to specify if you're looking for something that would work with templating, a web framework (like Kepler), something to fully generate responses in Lua (WSAPI) or are you looking to do something like embed an interpreter in the page like what is found on the Lua.org site? – James Snyder May 05 '11 at 06:25

3 Answers3

2

You could use lua directly if you set apache up with mod_lua, or IIS up with luaisapi.

Here is a link to CGILua.

Other than that, you could use shell_exec or exec with output parameter in php to execute the lua script and return the output. Or an equivalent method in ASP.

test.lua

print "Hello, World!"

runlua.php

<?php
      $output = shell_exec('lua test.lua');
      echo "<pre>$output</pre>";
?>
adorablepuppy
  • 1,077
  • 1
  • 7
  • 13
  • I would not recommend `runlua.php` solution for the production — only if you absolutely have to use it. Also, CGILua and other solutions you mention are a bit low-level. Take a look at my answer if you need higher-level stuff. – Alexander Gladysh May 02 '11 at 19:00
2

If you need to do this from server-side, you have a lot of choices. Most popular one would be WSAPI. Others are easily googleable. See also here for a bit outdated but still actual list.

If you want Lua on client-side, in browser, then you may want to look at Lua Alchemy (Lua in Flash) or aelua (Lua in JavaScript). Expect to get your hands dirty.

Community
  • 1
  • 1
Alexander Gladysh
  • 39,865
  • 32
  • 103
  • 160
2

You might be interested in the KeplerProject. It's sort of a framework for web application development in Lua.

jpjacobs
  • 9,359
  • 36
  • 45