PrimoFernando 7 Posted March 9, 2015 Hey, I defined a area on my scipt, how can i make the script store only trees inside that area? Thanks.
Vlad 216 Posted March 9, 2015 private final Filter<GameObject> tree_filter = new Filter<GameObject>() { @Override public boolean match(GameObject go) { if (go == null) { return false; } if (!cutArea.contains(go)) { return false; } return true; } }; GameObject tree = getGameObjects().closest(tree_filter);
Fran 99 Posted March 9, 2015 Lets say you hypothetically defined your Area as, cuttingArea. Your hatchet as Axe & stored values for the trees, this workaround code might help: if (!cuttingArea.contains(getPlayers().myPlayers().getTile()) && getInventory().contains(Axe)) { Tile[] tiles = cuttingArea.getTiles(); Tile cuttingAreaTiles = tiles[Calculations.random(0, tiles.length - 1)]; if (cuttingAreaTiles != null) { getWalking().walk(cuttingAreaTiles); //If you're not in the Area defined, this will //walk you to a random tile inside it else { //else, if you certainly are in the wcing Area, then execute your chopping actions if (tree != null && tree.isOnScreen()) { tree.interact("Chop down"); } } }
Pandemic 2853 Posted March 10, 2015 private final Filter tree_filter = new Filter() { @Override public boolean match(GameObject go) { if (go == null) { return false; } if (!cutArea.contains(go)) { return false; } return true; } }; GameObject tree = getGameObjects().closest(tree_filter); You can simplify that filter a lot with just this: return go != null && cutArea.contains(go);
Recommended Posts
Archived
This topic is now archived and is closed to further replies.