Rockbox Technical Forums

Support and General Use => Plugins/Viewers => Topic started by: SpawnHyuuga on October 29, 2010, 08:55:12 AM

Title: LUA Viewer
Post by: SpawnHyuuga on October 29, 2010, 08:55:12 AM
So obviously the LUA viewer is for viewing/executing LUA files - but what kind of files or where can we get LUA games/programs for use with Rockbox?
Title: Re: LUA Viewer
Post by: torne on October 29, 2010, 09:11:31 AM
You would probably have to write them. Lua is just a programming language, it's not a system that there is a large body of games/programs written for already, and even if there were some they aren't going to be able to run on Rockbox since you need to use Rockbox-specific APIs to do any input/output.
Title: Re: LUA Viewer
Post by: Chronon on October 29, 2010, 11:26:16 AM
If you look in the /.rockbox/rocks/games directory you can see that the Boomshine plugin is actually a lua script.
Title: Re: LUA Viewer
Post by: SpawnHyuuga on October 30, 2010, 09:46:24 PM
Well I knew there wasn't much of a database, but I did search for things written in LUA and got a lot of PSP stuff. I'm just wondering if any of it could be converted.
Title: Re: LUA Viewer
Post by: torne on October 31, 2010, 06:59:02 AM
Porting lua scripts for other platforms to rockbox is similar to porting things written in C for other platforms as plugins. The degree of changes required will vary depending what the script does.
Title: Re: LUA Viewer
Post by: gbl08ma on February 01, 2011, 04:39:34 PM
I think that Lua in Rockbox as lot of potential, specially because it doesn't require you to build a custom build to run a LUA plugin, it isn't affected by minor changes of the Rockbox version ("normal", C plugins report "Incompatible version"), it's much easier to share and cross-target (if the script isn't affected by the amount of memory or screen size of the device, you can just copy it to a different Rockbox player and it will run that script too). Also, Lua is, in some people's opinion, easier to learn and code than C.

In the sequence of this, I tried to develop a few simple plugins, to get one conclusion: there's no real documentation on how to use the Rockbox API to show usual things as menus. I added another code sample on the Lua viewer wiki page, which shows how to use the Menu API, and I plan on coding more sample Lua plugins as both a way to create more documentation on the subject and to learn Lua at the same time.

Lets hope that with these contributions, more Lua plugins are coded for Rockbox...

By the way, Lua can not only be used for coding plugins but also less elaborated scripts. For example, I made two very simple scripts that turn on and off the CPU boost, just by launching the Lua file on the browser.