Well, there was no proper library available for this purpose at all in java, so i pretty much wrote an implementation for OOP. All that was available was C-bindings, and that's it, this meant you had to work with the actual stack in order to retrieve data from a LUA-file.
So here's a neat little library that will allow you to parse lua-tables with ease. I love lua as a data-storage system as it's very light-weight, incredibly fast, and has a nice syntax.
Javadocs are included and the native library file for windows that is required. In case you need one for another operating system, get it here:
http://luabinaries.luaforge.net/download.html
There's an example on how to load a table and iterate it's values in com.easylua.examples.TableTest
In case you want an example right here:
Code:
package com.easylua.examples;
import com.easylua.*;
/**
* An example class on loading a table and outputting it's data.
*/
public class TableTest {
public static void main(String[] args) {
new TableTest();
}
public TableTest() {
LuaScript script = LuaScript.parse("./res/tabletest.lua");
LuaTable table = script.getTable("testTable");
printTable(table);
System.out.println("Test executed successfully!");
}
public void printTable(LuaTable table) {
for(LuaValue val : table.getValues()) {
if(val instanceof LuaBoolean) {
LuaBoolean bool = (LuaBoolean) val;
System.out.println(bool.getName() + " = " + bool.getValue());
} else if(val instanceof LuaNumber) {
LuaNumber num = (LuaNumber) val;
System.out.println(num.getName() + " = " + num.getValue());
} else if(val instanceof LuaString) {
LuaString string = (LuaString) val;
System.out.println(string.getName() + " = " + string.getValue());
} else if(val instanceof LuaTable) {
LuaTable tab = (LuaTable) val;
printTable(tab);
}
}
}
}
That's about it, i will be improving this overtime as i myself need more features from LUA in my projects.
Download Link:
http://usenet.eatddos.info/easylua/down ... ua-0.2.zip
I noticed my old link was broken so here is a working one. It is updated to revision 0.2 as well and contains some new functionality such as ability to call lua functions and get global variables.
Note: I didn't really know where to post this, so i hope this section is alright. It's not really open source at the moment, however that will happen soon enough
Enjoy
