Lua user and programmer. Lover of the "small things are beautiful" philosophy.
Currently developing an adventure game engine that will be using Lua as scripting engine: [Lixoo].
STUFF I MADE:
- LuaModuleShelve, a LGPL'ed Lua module that acts like Python's module of same name. This module is included in LuaCheia, too.
- LuaModuleLzo, a GPL'ed Lua module that wraps around the [miniLZO] compression library, making it available in Lua scripts.
- Simple script to demonstrate Lua capabilities: I like to get my colleagues frightened with the Jedi powers of Lua by showing them this filter script that puts line numbers in the standard input. Once they saw the script of only five lines, I always ask to them: "How many lines do you need to do the same in C?" Here it is (requires Lua 5.0):
i = 1;
for line in io.readlines() do
print(i .. ": ", line);
i = i+1;
end
- You could do this in one line in C :o) e.g.,
for (int i=1, b[100];;i++) printf("%d: %s\n",i,gets((char*)b));
- Or one line in Lua: --NDT
while 1 do i=(i or 0)+1 print(""..i..": "..io.read()) end
or
for i,ln in function(s,i) return i+1,""..i..": "..io.read() end,nil,1 do print(ln) end
- Yeah, you'll right ;), but the C code will crash if you use the program over a file with lines longer than the size of the buffer, and you need to declare the
main()
function and include stdio.h
... Maybe I often worry too much about code correctness and maybe that script was not a good example after all :P -- Adrian
- Well.. I don't think any of the last examples given may pass as one line of code. Going like that you can collapse a whole file onto i single line.. Don't get me wrong, I still find it very neat and I like Lua alot :o)
- Of course, if terseness is your goal, Perl will win every time: -- ET
while(<>) {print(++$i.": ".$_)}
- Heavens! I can't stand Perl, nearly anything I've seen written in Perl seems to me like a bunch of impossible-to-understand-mixed-style-code. But I recognize that your example is unbeatable ;) -- AdrianPerez
- Sorry by my interference, but for this problem awk is near invincible (reading from stdin):
awk '{print NR, $0}' -
- -- JulioFernandez
STUFF I'M MAKING:
These are Lua-related projects I'm currently working on:
- Lixoo: the "Lightweight Interpreter eXtensible and Object Oriented", an Open Source 2D adventure game engine. I'm really making a great effort with this. Will be using Lua 5.0 as scripting engine. [Official site].
- LuaCheia: I'm working on the MacOS X port of this modular and expansible Lua distribution.
- MoonSoon?: a simple WikiWikiEngine? written in Lua, can run in nearly any webserver with CGI support and a standard Lua 5.0 interpreter. In the near future the sources of a standalone version with some C code mixed with Lua code will be available. More info at [SourceForge].
STUFF I DIDN'T MAKE YET:
Ideas, ideas: ideas I had but they didn't work, or didn't implement them, or... as I want to work on Lixoo I don't have spare time to these.
- Build system: I agree with JohnBelmonte that a Lua-based build system could be very cool stuff. I had this idea without knowing that he had it too. I coded some time ago a bunch scripts and called it SBS (Scriptable Build System), but I never released it as it had lots of obscure things and didn't work well. I think that the building system can be done by coding a library to do certain system calls (especially those related to knowing modification dates of files) from Lua and packaging them with a custom Lua interpreter especially designed to perform builds of software.
- I had a go at this one: [moonmake] (documentation: [moonmake.txt]) -- xlq
- Some kind of mod_lua for [Apache]: I know there's one from [XTG-Systems] floating around there, but it's fairly simple. I know there's CGILua and I recognize it's great... but I'd like to see CGILua running on the Apache included in MacOS X, and there's no binary distribution for Macs. I think also that using an Apache module is faster that using a CGI program; at least this is what happens with [mod_python] and [mod_perl]. It should be nice if it had support for Apache2. Update: I have seen some different mod_lua implementations around there, even for Apache2, great!
RecentChanges · preferences
edit · history
Last edited August 3, 2010 10:18 pm GMT (diff)