• Status Closed
  • Percent Complete
  • Task Type Patches
  • Category Plugins
  • Assigned To No-one
  • Operating System All players
  • Severity Low
  • Priority Very Low
  • Reported Version Daily build (which?)
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: Rockbox
Opened by safetydan - 2008-07-09
Last edited by mcuelenaere - 2009-05-21

FS#9174 - Lua Scripting Language for Rockbox

Here is an (very, very) early proof of concept Lua viewer plugin (v.5.1.3).

Currently only a few functions are exported from the plugin API and it also lacks a setjmp/longjmp implementation for actual targets so error handling will go wrong very quickly.

However it does work so far for simple scripts like the following:

function sayhello(seconds)

  message = string.format("Hello from LUA for %d seconds", 5)
  rb.splash(seconds, message)


– Drawn an X on the screen
rb.drawline(0, 0, rb.LCD_WIDTH, rb.LCD_HEIGHT)
rb.drawline(rb.LCD_WIDTH, 0, 0, rb.LCD_HEIGHT)

seconds = 5

rb.sleep(5 * rb.HZ)


Closed by  mcuelenaere
2009-05-21 19:02
Reason for closing:  Accepted
Additional comments about closing:   Warning: Undefined array key "typography" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 371 Warning: Undefined array key "camelcase" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 407

in r21020

I forgot to mention that it’s designed to be used as a viewer of .lua files. So you would save the above example Lua file to test.lua on your target and then play it as you would any other file.

Nice patch, works fine on the sim! (can’t test on a device atm)

I’ve added some extra functions to the rb lib (see attached diff)

I reworked the patch a bit and make it work in the current tree.

I will test it later on a device but it looked good in sim.

I’m going to try it out on my c250. Looking forward to future developments =]

This is v2 with some more functions added, setjmp implementation and tested on target (Onda VX747 - works!).

The current patch also worked good on my e250. :-)

* updated to Lua 5.1.4
* added more functions to rocklib
* added ability to use audiobuffer when out of pluginbuffer RAM

Are there some open tasks?

You mean TODO’s before this gets committed?
AFAIK, this is pretty stable; but I would like to get another dev to confirm that..

* Fixes issue with line numbers not showing up when error occured

Nice stuff.

I tried v6 on the gigabeat and it looks as if numbers are not parsed correctly. I.e. the 5 seconds become 1075052544 - maybe to do with the fact that the only numerical datatype in LUA is float. Also the rectangle doesn’t get drawn - I suspect for the same reason.

In the simulator (cygwin) it is worse. To get it to compile I had to make the “int error_no = 0;” unconditional. I didn’t get it to draw anything, but the splash was displayed (with a rather big number).

You just missed the viewer.config.
But i got problems running the test script in the simulator.
The screen gets cleaned and nothing else happends.

* fixes sim build
* removes strtod
* adds strtol
* should completely remove floating-point support

If this version doesn’t break somewhere/something I’ll probably commit it soon.

Why remove floating point support?

* adds support for auto-generating ACTION_*
* adds some more wrappers
* adds the current path & /.rockbox/rocks/viewers/ to the search path when including files


Available keyboard shortcuts


Task Details

Task Editing