abouhanafy87 4 Share Posted July 19, 2021 public void checkRocks(){ rok1 = GameObjects.getTopObjectOnTile(new Tile(2501,5066, 0)); rok2 = GameObjects.getTopObjectOnTile(new Tile(2498,5065, 0)); rok3 = GameObjects.getTopObjectOnTile(new Tile(2504,5059, 0)); if (rok1 != null){ if(rok1.exists() && rok1.getID()==oreID && !rock1) { rock1 = true; log("rock 1 is now light ..o..");//this is work } }else { if(rock1){ rock1 = false; log("rock 1 is gone *"); } } if (rok2 != null){ if(rok2.exists() && rok2.getID()==oreID && !rock2) { rock2 = true; log("rock 2 is now light ..oo.."); } }else { if(rock2) { rock2 = false; log("rock 2 is gone **");// here not work } } if (rok3 != null){ if(rok3.exists() && rok3.getID()==oreID && !rock3) { rock3 = true; log("rock 3 is now light ..ooo.."); } }else { if(rock3) { rock3 = false; log("rock 3 is gone ***"); } } } Link to comment Share on other sites More sharing options...
TheCloakdOne 389 Share Posted July 19, 2021 So you can simplify it a bit but depends what your trying to do: Gameobject rock = Gameobjects.closest(oreID); Or to check only specific tiles like you are in your example you could use a filter: int oreID = 123; List<Tile> rockTiles = Arrays.asList(new Tile(2501,5066, 0),new Tile(2498,5065, 0),new Tile(2504,5059, 0)); GameObject rock = GameObjects.closest((g) -> g != null && g.getID() == oreID && rockTiles.contains(g.getTile())); If you are trying to see if the rock has been mined already or not, check its colour once rock != null Link to comment Share on other sites More sharing options...
ethan45 4 Share Posted July 28, 2021 On 7/20/2021 at 2:00 AM, abouhanafy87 said: public void checkRocks(){ rok1 = GameObjects.getTopObjectOnTile(new Tile(2501,5066, 0)); rok2 = GameObjects.getTopObjectOnTile(new Tile(2498,5065, 0)); rok3 = GameObjects.getTopObjectOnTile(new Tile(2504,5059, 0)); if (rok1 != null){ if(rok1.exists() && rok1.getID()==oreID && !rock1) { rock1 = true; log("rock 1 is now light ..o..");//this is work } }else { if(rock1){ rock1 = false; log("rock 1 is gone *"); } } if (rok2 != null){ if(rok2.exists() && rok2.getID()==oreID && !rock2) { rock2 = true; log("rock 2 is now light ..oo.."); } }else { if(rock2) { rock2 = false; log("rock 2 is gone **");// here not work } } if (rok3 != null){ if(rok3.exists() && rok3.getID()==oreID && !rock3) { rock3 = true; log("rock 3 is now light ..ooo.."); } }else { if(rock3) { rock3 = false; log("rock 3 is gone ***"); } } } Have a look at some guides you're doing some weird things Comment above is the basics of how to interact with objects ^ Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.