Rhetoric Posted January 18, 2016 Share Posted January 18, 2016 Area X: 2 Trees Area Y: 1 Tree How can I make is so that if my player is in Area Y and when that tree only is null, not the ones in Area X, my player runs to stand in Area X to wait for those trees to spawn or vice versa. I'm hoping there is a way to check for entities in a specific area and if they are null so that I can perform an action based off that info. Quote Link to comment Share on other sites More sharing options...
Snorunt Posted January 18, 2016 Share Posted January 18, 2016 id split the two areas and tree entities if that would work, then for example if (treex != null && myPlayer().getInteracting() == null){ if (!myPlayer().isMoving()){ if (treex.isVisible()) { treex.interact("chop"); }} } else if (treey != null && myPlayer().getInteracting() == null){ if (!myPlayer().isMoving()){ if (treey.isVisible()) { treey.interact("chop"); }} } Im rather new to scripting, so ignore me if im trying to go over my knowledge Quote Link to comment Share on other sites More sharing options...
Inbredd Posted January 18, 2016 Share Posted January 18, 2016 That shits complicated Quote Link to comment Share on other sites More sharing options...
Rhetoric Posted January 18, 2016 Author Share Posted January 18, 2016 That shits complicated Would making the character run to first cut tree when all are null be just as complicated? Quote Link to comment Share on other sites More sharing options...
Gold Scripts Posted January 18, 2016 Share Posted January 18, 2016 (edited) I'm hoping there is a way to check for entities in a specific area and if they are null so that I can perform an action based off that info. Entity tree = getObjects().closest("Yew tree"); Area AreaY = new Area(1, 2, 3, 4); Area AreaX = new Area(2, 3, 4, 2); if (!myPlayer.isMoving() && !myPlayer.isAnimating()) { if (tree != null && AreaY.contains(tree.getPosition())) { //if tree exists & is in AreaY if (AreaY.contains(myPlayer().getPosition())) { //if we are in AreaY tree.interact("chop"); //chop return true; } else getWalking().walk(AreaY.getRandomPosition());//We aren't in Area Y->walk there } else if (tree != null && AreaX.contains(tree.getPosition())) { //if tree exists & in AreaX if (AreaX.contains(myPlayer().getPosition())) { //if we are in AreaX tree.interact("chop"); // chop tree return true; } else getWalking().walk(AreaX.getRandomPosition()); //we aren't in Area X->walk there } Edited January 18, 2016 by Gold Scripts 2 Quote Link to comment Share on other sites More sharing options...
Rhetoric Posted January 18, 2016 Author Share Posted January 18, 2016 Entity tree = getObjects().closest("Yew tree"); Area AreaY = new Area(1, 2, 3, 4); Area AreaX = new Area(2, 3, 4, 2); if (!myPlayer.isMoving() && !myPlayer.isAnimating()) { if (tree != null && AreaY.contains(tree.getPosition())) { //if tree exists & is in AreaY if (AreaY.contains(myPlayer().getPosition())) { //if we are in AreaY tree.interact("chop"); //chop return true; } else getWalking().walk(AreaY.getRandomPosition());//We aren't in Area Y->walk there } else if (tree != null && AreaX.contains(tree.getPosition())) { //if tree exists & in AreaX if (AreaX.contains(myPlayer().getPosition())) { //if we are in AreaX tree.interact("chop"); // chop tree return true; } else getWalking().walk(AreaX.getRandomPosition()); //we aren't in Area X->walk there } Thanks! 1 Quote Link to comment Share on other sites More sharing options...