GP2X Gplua2x


pelle

Still Fresh
Joined
Nov 21, 2008
Messages
1
Hello. In case someone is interested in using a bit of lua scripting on the gp2x I uploaded my port to github a while ago: http://github.com/lifelike/gplua2x/tree/master

It's not just a port of the language itself (which is basically trivial to do anyway - 2 or 3 lines to modify). While you can use liblua.a to embed scripts into C or C++ programs, I also added some SDL wrapper functions (libgplua2x.a). So far it's only the basic stuff you need to load PNG images, do some blitting, read joystick input (ie no sound), and helper function to run a mainloop calling back provided lua functions for each tick and button presesd (see looptest.lua and libtest.lua). You can use it as a really simple and lightweight (but limited) pygame sort of, writing a game in 100 % Lua, or you can write a game in C just using a few calls to plain lua scripts to do some minor work.

The first files you may want to look at are license.txt and index.html.

Here is a statically precompiled version of gplua2xrun, compiled using some fairly recent version of open2x:
http://pelle-n.net/gplua2xrun.zip
(An example start script is also on github, looptest.gpe. Trivial 2-liner really...)

The bad news is that compiling from the source is a bit tricky, if you need that for some reason.You can use git to get it from github ("git clone git://github.com/lifelike/gplua2x,git") You need a C compiler, SDL, SDL-image, libpng, Lua (liblua actually),... maybe something I forgot, to compile it for your PC (for testing). The included Makefile has rules for "make linux" and "make freebsd", but if you run Windows or something it shouldn't be too tricky to compile once you have managed to install SDL properly. To compile for the gp2x you need the open2x libs and binaries, including SDL for the gp2x, and run "make gp2x". Make will create not only gplua2xrun but also the static libs you can use if you rather want to link gplua2x (or just plain lua) into your C or C++ program.

I hope someone finds some fun use for it. If you want to improve it you can always fork it on github. If you come up with something interesting enough I will be happy to merge it back into the main project. The next thing I think I want to add is some kind of proper font/text support. Sound is much lower on my prio list since I almost never run games with sound turned on on handhelds anyway.
 
Last edited by a moderator:
Back
Top