January 18, 201610 yr 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.
January 18, 201610 yr 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
January 18, 201610 yr Author That shits complicated Would making the character run to first cut tree when all are null be just as complicated?
January 18, 201610 yr 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, 201610 yr by Gold Scripts
January 18, 201610 yr Author 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!
Create an account or sign in to comment