read a .we minetest schema

- use ground has maze walls
This commit is contained in:
philippe lhardy
2020-11-04 22:12:17 +01:00
parent 6402766371
commit 52a2d3f1e3
13 changed files with 430 additions and 16 deletions

View File

@@ -0,0 +1,51 @@
package org.artisanlogiciel.games.minetest;
import org.artisanlogiciel.lua.CharProvider;
import org.artisanlogiciel.lua.LuaObject;
import org.artisanlogiciel.lua.Parser;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
public class WorldEditReader {
InputStream input;
public WorldEditReader(InputStream pIn)
{
input = pIn;
}
public World read()
throws IOException
{
World world = new World();
BufferedReader in = new BufferedReader(new InputStreamReader(input));
byte b[] = new byte[128*1024];
input.read(b);
String contents = new String(b);
in.close();
System.out.println(contents);
CharProvider reader = new CharProvider(contents);
Parser parser = new Parser(reader);
LuaObject result = parser.parse();
if (result != null) {
System.out.println(result.toString());
Object we = result.wrapToJava();
System.out.println(we);
world.addList( (List<Object>) we);
System.out.println(world);
} else {
System.err.println("result null");
}
return world;
}
}