Athylus Posted August 5, 2018 Share Posted August 5, 2018 Do you have the required axe in your bank at all? Aftering checking if the bank is open, nest another if statement (or use a logical operator on the same line) that checks whether the axe is in your bank at all. If (bank.contains(Axetouse) && bank.withdraw(Axetouse, 1)) new ConditionalSleep(3000, 25). Return on that sleep whether your inventory contains the axe. 1 Quote Link to comment Share on other sites More sharing options...
heervangrijsburg Posted August 6, 2018 Author Share Posted August 6, 2018 Axe was in the bank and i had already added the if statement to look if the axe was in the bank but thanks anyway Now I´m trying to create the script that if the axe isn´t in the bank he will sell the logs you harvested and buy the axe but I can't figure out how to open the offer slot in the ge (note i'm already in the ge ). RS2Widget Openbuymenu = getWidgets().get(465, 7, 26); if(Openbuymenu != null) { Openbuymenu.interact("Buy"); new ConditionalSleep(5000) { public boolean condition() throws InterruptedException { return grandExchange.isOfferScreenOpen(); } }.sleep(); } keyboard.typeString(AxeToUse()); int Offerprice = grandExchange.getOfferPrice(); grandExchange.setOfferPrice( 2 * Offerprice ); Quote Link to comment Share on other sites More sharing options...
Athylus Posted August 6, 2018 Share Posted August 6, 2018 Have you looked at this? https://osbot.org/api/org/osbot/rs07/api/GrandExchange.html#buyItem-int-java.lang.String-int-int- 1 Quote Link to comment Share on other sites More sharing options...
heervangrijsburg Posted August 6, 2018 Author Share Posted August 6, 2018 I watched it, but I wanted to learn how to work with widgets. It would be possible with widgets if I am not mistaken. but I will look again to your link and try it out and if it is possible could you still tell me what was wrong with my code for the future. Quote Link to comment Share on other sites More sharing options...
Athylus Posted August 6, 2018 Share Posted August 6, 2018 9 minutes ago, heervangrijsburg said: It would be possible with widgets if I am not mistaken. It would be. I commend you for creating your own methods for the GE. Are you certain that "Buy" is the right interact string? When hovering I see "Create Buy offer". Alternatively, you can ask for the x, y coordinate of that widget and create a rectangle based on the x, y, width and height. Then you can click on that with the mouse class. 1 Quote Link to comment Share on other sites More sharing options...
heervangrijsburg Posted August 12, 2018 Author Share Posted August 12, 2018 (edited) hello, thanks @Steel Poster but I now use "grandExchange.buyItem". Now I´m getting this error and i don´t know how to fix it : this is the part of the code I think the problem is in but like I said I don´t know how to fig it Main class Spoiler package script; import items.Axe; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import tasks.*; @ScriptManifest(author = "Heervangrijsburg", logo = "", info ="Cuts trees" , version = 1.2 , name = "Tree chopper") public final class Main extends Script { private final GoChopTree goChopTree = new GoChopTree(); private final GoBank goBank = new GoBank(); private final Axe axe = new Axe(); private final GoGetAxe gogetaxe = new GoGetAxe(); @SuppressWarnings("deprecation") @Override public void onStart() { goChopTree.exchangeContext(getBot()); goBank.exchangeContext(getBot()); axe.exchangeContext(getBot()); gogetaxe.exchangeContext(getBot()); } @Override public void onExit() { } @Override public int onLoop() throws InterruptedException { log("start oke"); if (inventory.isEmptyExcept(1511, 1353,1361,1355,1357,1359,1351)) { log ("section 2"); if (!inventory.isFull()) { log ("section 3"); if (inventory.contains(axe.AxeToUseName())) { log ("section 4"); goChopTree.choptree(); } else { gogetaxe.getsrightaxe(); } } else { log ("section 2,1"); goBank.bankafterchopptingtrees(); } } else { log ("section 1,1"); goBank.bankinventoryjunk(); } return 1000; } } GoGetAxe class : Spoiler package tasks; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.MethodProvider; import org.osbot.rs07.utility.ConditionalSleep; import items.Axe; import pricege.*; public final class GoGetAxe extends MethodProvider { private Axe axe = new Axe(); private Area bank_area = new Area( new int[][]{ { 3092, 3246 }, { 3092, 3240 }, { 3097, 3240 }, { 3097, 3246 } } ); private Area grandexchange_Area = new Area( new int[][]{ {3162, 3486}, {3168, 3486}, {3168, 3493}, {3161, 3492} } ); public void getsrightaxe() throws InterruptedException { if (bank_area.contains(myPlayer())) { if (bank.isOpen()){ if (bank.contains(axe.AxeToUseName())){ bank.withdraw(axe.AxeToUseName(), 1); } else { buyrightaxe(); } bank.close(); new ConditionalSleep(5000){ public boolean condition() throws InterruptedException { return !bank.isOpen(); } }.sleep(); } else { bank.open(); new ConditionalSleep(5000){ public boolean condition() throws InterruptedException { return bank.isOpen(); } }.sleep(); } } else { getWalking().webWalk(bank_area); new ConditionalSleep(5000) { public boolean condition() throws InterruptedException { return bank_area.contains(myPlayer()); } }.sleep(); } } Axe class Spoiler package items; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.MethodProvider; public class Axe extends MethodProvider { public String AxeToUseName() { if (skills.getDynamic(Skill.WOODCUTTING) <= 10) { return "Steel axe"; } else if (skills.getDynamic(Skill.WOODCUTTING) <= 20) { return "Black axe"; } else if (skills.getDynamic(Skill.WOODCUTTING) <= 30) { return "Mithril axe"; } else if (skills.getDynamic(Skill.WOODCUTTING) <= 40) { return "Adamant axe"; } else if (skills.getDynamic(Skill.WOODCUTTING) <= 99) { return "Rune axe"; } else { return "bronze axe"; } } public int AxeToUseID() { if (skills.getDynamic(Skill.WOODCUTTING) <= 10) { return 1353; } else if (skills.getDynamic(Skill.WOODCUTTING) <= 20) { return 1361; } else if (skills.getDynamic(Skill.WOODCUTTING) <= 30) { return 1355; } else if (skills.getDynamic(Skill.WOODCUTTING) <= 40) { return 1357; } else if (skills.getDynamic(Skill.WOODCUTTING) <= 99) { return 1359; } else { return 1351; } } } Edited August 12, 2018 by heervangrijsburg adding Axe class Quote Link to comment Share on other sites More sharing options...
Athylus Posted August 12, 2018 Share Posted August 12, 2018 (edited) Possibly because you are calling the Axe class from GoGetAxe class and have not exchangedContext between these two classes. Can't say for sure. Let me know if that works, or if it does not. Edited August 12, 2018 by Athylus Quote Link to comment Share on other sites More sharing options...
heervangrijsburg Posted August 13, 2018 Author Share Posted August 13, 2018 Thanks it worked I´m getting an other error now but I haven´t had time to look into it myself if I can't figure it out I will let you know. Thanks for the help so far. Quote Link to comment Share on other sites More sharing options...
Rays Posted August 13, 2018 Share Posted August 13, 2018 (edited) If I were you, I'd take a look into what classes/methods are just in general in Java. It seems like you have classes for simple tasks where methods would be sufficient. Having a class for just a small task is not advised and very bad coding habits. Look into object-oriented programming as that's what Java was developed for Edited August 13, 2018 by Rays Quote Link to comment Share on other sites More sharing options...