kolmassammas 0 Share Posted December 28, 2020 When I see the logs in my console my last one is interacted with bank. That should mean getBank().isOpen() dosen't work right? My bank opens up but yeah i dosen't recognize it. For whatever reason it dosen't open. Is there any other way to deposit all of my invetory to the bank without checking the getBank().isOpen statement. Link to comment Share on other sites More sharing options...
Pseudo 179 Featured Comment Share Posted December 28, 2020 You have zero logic to your code, so it'll always try to execute all of those actions, in that order, constantly, so that's the biggest problem. You need to structure your code. Secondly you ought to now use DB3's static API. [code] private void exampleBankingMethod() { GameObject bank = GameObjects.closest("Bank booth"); if (!Bank.isOpen()) { // Check if bank ISN'T open if (bank != null) { // Check the bank booth exists/isn't null if (bank.isOnScreen()) { //Bank exists and we can see it if (bank.interact("Bank")) { //if we clicked the bank sleepUntil(Bank::isOpen, 5000); // wait until bank is open or 5 seconds have passed } } else { // Bank exists but we can't see it! Need to turn to it or move to it Walking.walk(bank.getTile().getRandomizedTile(2)); //Move to the bank } } else { //If bank is null do this Walking.walk(ourTargetBankLocationTile); } } else { //If bank IS open do this if (!Inventory.isEmpty()) { //If theres items in inventory do this if (Bank.depositAllItems()) { sleepUntil(Inventory::isEmpty, 3000); //dynamic sleep to wait until we deposited our items } } else { //We don't have items, do we withdraw or do we exit the bank? if (Bank.close()) { sleepUntil(() -> !Bank.isOpen(), 3000); // wait until bank is closed or 3 seconds have passed } } } } [/code] Just minced this together to try and help you better understand how operations should be handled. Link to comment Share on other sites More sharing options...
kolmassammas 0 Author Share Posted December 29, 2020 13 hours ago, Pseudo said: You have zero logic to your code, so it'll always try to execute all of those actions, in that order, constantly, so that's the biggest problem. You need to structure your code. Secondly you ought to now use DB3's static API. [code] private void exampleBankingMethod() { GameObject bank = GameObjects.closest("Bank booth"); if (!Bank.isOpen()) { // Check if bank ISN'T open if (bank != null) { // Check the bank booth exists/isn't null if (bank.isOnScreen()) { //Bank exists and we can see it if (bank.interact("Bank")) { //if we clicked the bank sleepUntil(Bank::isOpen, 5000); // wait until bank is open or 5 seconds have passed } } else { // Bank exists but we can't see it! Need to turn to it or move to it Walking.walk(bank.getTile().getRandomizedTile(2)); //Move to the bank } } else { //If bank is null do this Walking.walk(ourTargetBankLocationTile); } } else { //If bank IS open do this if (!Inventory.isEmpty()) { //If theres items in inventory do this if (Bank.depositAllItems()) { sleepUntil(Inventory::isEmpty, 3000); //dynamic sleep to wait until we deposited our items } } else { //We don't have items, do we withdraw or do we exit the bank? if (Bank.close()) { sleepUntil(() -> !Bank.isOpen(), 3000); // wait until bank is closed or 3 seconds have passed } } } } [/code] Just minced this together to try and help you better understand how operations should be handled. Thanks, at first i got this really weird error message with your code. Hasseled a bit. Found out i had to reintall my intellij and dreambot. Now your code is working flawlessly. This really helped me with constructing logic in my programs. Again Thanks. Link to comment Share on other sites More sharing options...
Pseudo 179 Share Posted December 29, 2020 You're welcome. Keep at it! Link to comment Share on other sites More sharing options...
Hashtag 8670 Share Posted December 30, 2020 On 12/29/2020 at 1:47 AM, Pseudo said: You have zero logic to your code, so it'll always try to execute all of those actions, in that order, constantly, so that's the biggest problem. You need to structure your code. Secondly you ought to now use DB3's static API. [code] private void exampleBankingMethod() { GameObject bank = GameObjects.closest("Bank booth"); if (!Bank.isOpen()) { // Check if bank ISN'T open if (bank != null) { // Check the bank booth exists/isn't null if (bank.isOnScreen()) { //Bank exists and we can see it if (bank.interact("Bank")) { //if we clicked the bank sleepUntil(Bank::isOpen, 5000); // wait until bank is open or 5 seconds have passed } } else { // Bank exists but we can't see it! Need to turn to it or move to it Walking.walk(bank.getTile().getRandomizedTile(2)); //Move to the bank } } else { //If bank is null do this Walking.walk(ourTargetBankLocationTile); } } else { //If bank IS open do this if (!Inventory.isEmpty()) { //If theres items in inventory do this if (Bank.depositAllItems()) { sleepUntil(Inventory::isEmpty, 3000); //dynamic sleep to wait until we deposited our items } } else { //We don't have items, do we withdraw or do we exit the bank? if (Bank.close()) { sleepUntil(() -> !Bank.isOpen(), 3000); // wait until bank is closed or 3 seconds have passed } } } } [/code] Just minced this together to try and help you better understand how operations should be handled. I want to emphasize that you're getting the bank object even if bank is already open. Only search for entities when you need them. In the worst case I have seen a scripter find dozens of entities in the beginning of each loop, and not even using any of them during that loop. Link to comment Share on other sites More sharing options...
Pseudo 179 Share Posted December 30, 2020 6 hours ago, Hashtag said: I want to emphasize that you're getting the bank object even if bank is already open. Only search for entities when you need them. In the worst case I have seen a scripter find dozens of entities in the beginning of each loop, and not even using any of them during that loop. Yeah nice catch! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.