12-13-2008, 07:22 AM | #1 |
JSR FFD2
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
|
Lua: scripting for Iliad
Hi All,
Lua is a scripting language. And it's running on my Iliad right now! It's easy to learn (if you are used to programing), its interpreted (you don't have to compile anything), it's fast and small (the executable is 128K). Much smaller than perl, python or ruby; much easier and fun than shell scripts, awk, sed... Lua is even cooler than it looks at first glance: it's easy to extend it (write functions in C, and call them from lua), or embed a lua interpreter in a C-program (it's used for scripting in game engines, camera's, ...) The attached file contains the Lua binary with extensions for network stuff (luasocket) and XML parsing (luaexpat). This is enough to fetch files from Internet (ftp, http) and parse rss feeds. Unpacked it's less than 400K. Is this cool or is it not? I can feel the karma If you are interested to compile this stuff yourself: I keep notes on http://wiki.hpelbers.org/Other_stuff_for_the_Iliad. It's not complete or well maintained, but it might save some time... Lua can be installed on your Iliad as follows: Code:
tar xvfz lua_for_iliad.tar.gz cd lua_for_iliad cp -r * /usr/local Happy scripting Hansel Links:
PS2: I'm just playing with this: not going to maintain or document it Last edited by hansel; 12-13-2008 at 03:04 PM. Reason: added link to tutorials and ref manual |
12-13-2008, 07:57 AM | #2 |
Guru
Posts: 976
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
|
The Lua website declares that it's some script for game (if I read it correctly). Do we have some example to run on iLiad?
|
12-13-2008, 08:30 AM | #3 | |
JSR FFD2
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
|
Hi ericshliao,
Quote:
Lua is not only for games: it's a full blown general purpose language. You can do anything you want with files, numbers, regular expressions, sockets, whatever. It's used in games because it's small, fast, and easy to embed. String handling is much easier than in C. You don't have to compile: you can test on your PC, and run on your Iliad by just copying the file. Plus it can do what you normally do with shell scripts... I'm still learning Lua (used to C, C++ and Ruby), but I like what I see! Here's a small example with file io and (cryptic ) string stuff: you can save it as hexdump.lua Code:
local index = 0 -- offset in file local block = 16 -- bytes on a line -- process file if given, else read from stdin if arg[1] then io.input(arg[1]) end while true do local bytes = io.read(block) if not bytes then break end io.write(string.format("%04X: ", index)) -- byte counter for b in string.gfind(bytes, ".") do io.write(string.format("%02X ", string.byte(b))) -- hex values end io.write(string.rep(" ", block - string.len(bytes) + 1)) io.write(string.gsub(bytes, "%c", "."), "\n") -- ascii values index = index+block end Code:
echo "hello" | lua hexdump.lua # read from standard input lua hexdump.lua /etc/passwd # read a file and dump it lua hexdump.lua </etc/passwd # use file content as input Last edited by hansel; 12-15-2008 at 05:59 AM. Reason: correct version of example |
|
12-14-2008, 07:51 PM | #4 |
Member
Posts: 13
Karma: 10
Join Date: Nov 2008
Device: Various
|
This is really cool - Lua is a really interesting language, definitely not just for games. It seems like it would be a good fit for writing Iliad apps, for sure - lightweight, extensible, fast. Adobe Lightroom is about 70% Lua.
Cheers, Colin |
Tags |
iliad, lua, scripting |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Scripting with epub-meta | averyml | Calibre | 20 | 11-17-2016 11:13 AM |
DR800 Lua 5.1 MegaPackage for DR800 | Iñigo | iRex | 25 | 10-05-2011 05:11 PM |
DR800 ANN: RunDebug and Icon lua scripts | Iñigo | iRex | 4 | 07-21-2010 08:35 AM |
Possible scripting engine for Sigil | Valloric | Sigil | 48 | 10-17-2009 10:58 AM |
Any NetNewsWire Scripting Pros out there? | adinb | Sony Reader | 0 | 02-25-2007 02:44 AM |