November 30, 201510 yr Hi Osbot scripters! I have been f*cking around with this all morning. I have no idea what i'm doing wrong. removing the } else { wont work either.. Oaks and Willows are working. Yews are not.. EDIT: Tried Else if statements. Didn't work either. case CHOP: Entity Yew = objects.closest("Yew"); Entity Willow = objects.closest("Willow"); Entity Oak = objects.closest("Oak"); if (Willow != null) { if (Willow.isVisible()) { Willow.interact("Chop down"); } else { sleep(random(500, 700)); } } else if (Oak != null) { if (Oak.isVisible()) { Oak.interact("Chop down"); } else { sleep(random(500, 700)); } } else if (Yew != null) { if (Yew.isVisible()) { Yew.interact("Chop down"); } else { sleep(random(500, 700)); } } case CHOP: Entity Willow = objects.closest("Willow"); if (Willow != null) { if (Willow.isVisible()) { Willow.interact("Chop down"); } else { sleep(random(500, 700)); } } else { Entity Oak = objects.closest("Oak"); if (Oak != null) { if (Oak.isVisible()) { Oak.interact("Chop down"); } else { sleep(random(500, 700)); } } else { Entity Yew = objects.closest("Yew"); if (Yew != null) { if (Yew.isVisible()) { Yew.interact("Chop down"); } else { sleep(random(500, 700)); } } } } Edited November 30, 201510 yr by OSRS Sebastian
November 30, 201510 yr Have you tried adding logs log("Can I reach this statement?"); and also what does your getState look like? You should also look into the InteractionEvent API. it handles visibility checks etc. Real easy to use http://osbot.org/api/org/osbot/rs07/event/InteractionEvent.html EXAMPLE SNIPPET: public boolean interact(final Entity entity, final String option) { InteractionEvent IE = new InteractionEvent(entity, option); IE.setOperateCamera(false); IE.setWalkTo(false); IE.setHover(true); if(IE != null) { execute(IE); //other checks } } // if (interact(tree,"Chop")) /// Edited November 30, 201510 yr by Trinity
November 30, 201510 yr Author Have you tried adding logs log("Can I reach this statement?"); and also what does your getState look like? You should also look into the InteractionEvent API. it handles visibility checks etc. Real easy to use I will look into interactionEvent. But i find it very difficult to understand the api somehow.. private State getState() { Entity treeE = objects.closest(tree); if (inventory.isFull()) return State.BANK; if (treeE != null && treeE.isVisible()) if (!myPlayer().isAnimating()) return State.CHOP; return State.WAIT; } private enum State { CHOP, WAIT, BANK, // DROP };
November 30, 201510 yr I will look into interactionEvent. But i find it very difficult to understand the api somehow.. private State getState() { Entity treeE = objects.closest(tree); if (inventory.isFull()) return State.BANK; if (treeE != null && treeE.isVisible()) if (!myPlayer().isAnimating()) return State.CHOP; return State.WAIT; } private enum State { CHOP, WAIT, BANK, // DROP }; Looks okay to me. You said it works for 2 trees? Can you throw in some log statements inside the case and run it for me?
November 30, 201510 yr Author Looks okay to me. You said it works for 2 trees? Can you throw in some log statements inside the case and run it for me? Will do. Just put some logs in every case? Like: "Going to bank", "Chopping willows" bla bla?
November 30, 201510 yr Yes or just in the Chop case between each tree Edited November 30, 201510 yr by Trinity
November 30, 201510 yr Author Yes or just in the Chop case between each tree Have set a log for every tree type. Willow and Oak logs perfectly. But the Yew log doesn't show up.. so i'm guessing it doesn't read that peace of code.. [INFO][Bot #1][11/30 02:09:51 PM]: Started script : SBWoodcutter [INFO][Bot #1][11/30 02:09:52 PM]: Chopping Oak tree [INFO][Bot #1][11/30 02:09:56 PM]: Script SBWoodcutter has paused! [INFO][Bot #1][11/30 02:09:58 PM]: Script SBWoodcutter has resumed! [INFO][Bot #1][11/30 02:09:58 PM]: Chopping Oak tree case CHOP: Entity Yew = objects.closest("Yew"); Entity Willow = objects.closest("Willow"); Entity Oak = objects.closest("Oak"); if (Willow != null) { if (Willow.isVisible()) { Willow.interact("Chop down"); log("Chopping Willow tree"); } else { sleep(random(500, 700)); } } else if (Oak != null) { if (Oak.isVisible()) { Oak.interact("Chop down"); log("Chopping Oak tree"); } else { sleep(random(500, 700)); } } else if (Yew != null) { if (Yew.isVisible()) { Yew.interact("Chop down"); log("Chopping Yew tree"); } else { sleep(random(500, 700)); } } break;
November 30, 201510 yr Have set a log for every tree type. Willow and Oak logs perfectly. But the Yew log doesn't show up.. so i'm guessing it doesn't read that peace of code.. [INFO][Bot #1][11/30 02:09:51 PM]: Started script : SBWoodcutter [INFO][Bot #1][11/30 02:09:52 PM]: Chopping Oak tree [INFO][Bot #1][11/30 02:09:56 PM]: Script SBWoodcutter has paused! [INFO][Bot #1][11/30 02:09:58 PM]: Script SBWoodcutter has resumed! [INFO][Bot #1][11/30 02:09:58 PM]: Chopping Oak tree case CHOP: Entity Yew = objects.closest("Yew"); Entity Willow = objects.closest("Willow"); Entity Oak = objects.closest("Oak"); if (Willow != null) { if (Willow.isVisible()) { Willow.interact("Chop down"); log("Chopping Willow tree"); } else { sleep(random(500, 700)); } } else if (Oak != null) { if (Oak.isVisible()) { Oak.interact("Chop down"); log("Chopping Oak tree"); } else { sleep(random(500, 700)); } } else if (Yew != null) { if (Yew.isVisible()) { Yew.interact("Chop down"); log("Chopping Yew tree"); } else { sleep(random(500, 700)); } } break; add my skype: osbotsinatra1
November 30, 201510 yr Author add my skype: osbotsinatra1 Will do. Problem is that i'm free from school in 5 mins. Can i come back later this day?
November 30, 201510 yr Will do. Problem is that i'm free from school in 5 mins. Can i come back later this day? Yeah we can do this later. I also have school in an hour.
November 30, 201510 yr Author Yeah we can do this later. I also have school in an hour. Alright, thanks. Will contact you later this day.
November 30, 201510 yr Hi Osbot scripters! I have been f*cking around with this all morning. I have no idea what i'm doing wrong. removing the } else { wont work either.. Oaks and Willows are working. Yews are not.. EDIT: Tried Else if statements. Didn't work either. case CHOP: Entity Yew = objects.closest("Yew"); Entity Willow = objects.closest("Willow"); Entity Oak = objects.closest("Oak"); if (Willow != null) { if (Willow.isVisible()) { Willow.interact("Chop down"); } else { sleep(random(500, 700)); } } else if (Oak != null) { if (Oak.isVisible()) { Oak.interact("Chop down"); } else { sleep(random(500, 700)); } } else if (Yew != null) { if (Yew.isVisible()) { Yew.interact("Chop down"); } else { sleep(random(500, 700)); } } case CHOP: Entity Willow = objects.closest("Willow"); if (Willow != null) { if (Willow.isVisible()) { Willow.interact("Chop down"); } else { sleep(random(500, 700)); } } else { Entity Oak = objects.closest("Oak"); if (Oak != null) { if (Oak.isVisible()) { Oak.interact("Chop down"); } else { sleep(random(500, 700)); } } else { Entity Yew = objects.closest("Yew"); if (Yew != null) { if (Yew.isVisible()) { Yew.interact("Chop down"); } else { sleep(random(500, 700)); } } } } Probably just that there isn't a Yew tree nearby?? Also if you are near a Yew tree, and there is an Oak or Willow nearby it will try and cut those first. I suggest you change your yew code to: else { Entity Yew = getObjects().closest("Yew"); if (Yew != null) { if (Yew.isVisible()) { log("Chopping Yew"); Yew.interact("Chop down"); } else { log("Yew is not visible"); sleep(random(500, 700)); } } else{ log("Yew is null"); } } And view the logger so you can see what's happening. On a side note your code can be simplified to: case CHOP: Entity yew = getObjects().closest("Yew"), willow = getObjects().closest("Willow"), oak = getObjects().closest("Oak"); if (willow != null && willow.isVisible()) willow.interact("Chop down"); else if (oak != null && oak.isVisible()) oak.interact("Chop down"); else if (yew != null && yew.isVisible()) yew.interact("Chop down"); else sleep(random(500, 700)); Side note 2: variable names should always be lowercase I would also suggest you take a look at Java Swing, there are some tutorials here on OSBot, and create a GUI that lets the user select which kind of tree they want to chop. Edited November 30, 201510 yr by Explv
November 30, 201510 yr Author Probably just that there isn't a Yew tree nearby?? Also if you are near a Yew tree, and there is an Oak or Willow nearby it will try and cut those first. I suggest you change your yew code to: else { Entity Yew = getObjects().closest("Yew"); if (Yew != null) { if (Yew.isVisible()) { log("Chopping Yew"); Yew.interact("Chop down"); } else { log("Yew is not visible"); sleep(random(500, 700)); } } else{ log("Yew is null"); }}And view the logger so you can see what's happening.On a side note your code can be simplified to: case CHOP: Entity yew = getObjects().closest("Yew"), willow = getObjects().closest("Willow"), oak = getObjects().closest("Oak"); if (willow != null && willow.isVisible()) willow.interact("Chop down"); else if (oak != null && oak.isVisible()) oak.interact("Chop down"); else if (yew != null && yew.isVisible()) yew.interact("Chop down"); else sleep(random(500, 700));Side note 2: variable names should always be lowercaseI would also suggest you take a look at Java Swing, there are some tutorials here on OSBot, and create a GUI that lets the user select which kind of tree they want to chop. Hey! Thanks for the reply. I will try this after dinner. Thing is, i have a GUI. Works on willows and oaks. But the yew he cant find. Even tho i'm standing next to it. Maybe insert the id of the yew instead of the name? And for the lower case vars. Thanks, really apriciate it!
November 30, 201510 yr Hey! Thanks for the reply. I will try this after dinner. Thing is, i have a GUI. Works on willows and oaks. But the yew he cant find. Even tho i'm standing next to it. Maybe insert the id of the yew instead of the name? And for the lower case vars. Thanks, really apriciate it! Feel free to PM me and I can take a look at the full source code for you
Create an account or sign in to comment