Jueix Posted April 3, 2023 Share Posted April 3, 2023 So I'm randomly coding scripts that I feel like I may need for my bot farm and I hate dealing with widgets / interfaces due to my bots spamming the item a few times before realising the interface is actually up. Here's the code I have for the last room in stronghold of security for floor 1. (Made a bot that does stronghold yes I am a noob and to lazy to manually do it). [code] if(WarEnd.contains(myPlayer())) { log("We are in the end room now"); RS2Widget widget1 = getWidgets().get(579, 17); if (dialogues.isPendingContinuation() && WarEnd.contains(myPlayer())) { log("JSS Floor 1: Interacting with chest dialogs"); dialogues.clickContinue(); } Item coins = getInventory().getItem("Coins"); if(coins.getAmount() >= 2000) { log("Detected coins in inventory going to floor 2"); RS2Object ladder = getObjects().closest(o -> o != null && o.getName().equals("Ladder") && o.getPosition().equals(new Position(1902, 5222, 0))); if (ladder != null && !myPlayer().isAnimating() && !myPlayer().isMoving() && !dialogues.isPendingContinuation()) { ladder.interact("Climb-down"); Timing.waitCondition( () -> getWidgets().get(579, 17).isVisible(), 30000); } if(widget1 != null) { if (widget1.isVisible()) { ScriptStatus = "Should be heading to floor 2."; if (widget1.interact()) { Floor = "Catacomb of Famine"; ScriptStatus = "Interacting with gate 1"; Timing.waitCondition( () -> !WarEnd.contains(myPlayer()), 10000); } } } } if(coins.getAmount() < 2000) { RS2Object giftofpeace = getObjects().closest(o -> o != null && o.getName().equals("Gift of Peace") && o.getPosition().equals(new Position(1907, 5222, 0))); if (giftofpeace != null && !myPlayer().isAnimating() && !myPlayer().isMoving() && !inventory.contains("Coins") && !dialogues.isPendingContinuation()) { giftofpeace.interact("Open"); ScriptStatus = "Interacting with gift of peace"; log("JSS Floor 1: Attempting Interaction with gift of peace"); /*try { discordMessage("redacted", "Floor 1 has now been completed, See that wasn't hard to code was it. Now code floor 2 lazy ass noob!", "Jueixs Stronghold of Security"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }*/ Timing.waitCondition(() -> dialogues.isPendingContinuation(), 10000); } } [/code] So Basically it will click the ladder 3 - 5 times (the interface will open and it will close the interface by clicking the ladder again and after a while it will realise the interface is finally open and go down. I've also placed the code for the ladder at the top of the script and it will still do it. Quote Link to comment Share on other sites More sharing options...
Gunman Posted April 3, 2023 Share Posted April 3, 2023 @Jueix Pretty sure you included your discord webhook, I removed it for you Quote Link to comment Share on other sites More sharing options...
ExtraBotz Posted April 3, 2023 Share Posted April 3, 2023 Is this your first bot? Stronghold of security is a very large undertaking for a new scripter. I would recommend starting with shorter tasks like easy quests to familiarize yourself with the API and how widgets work. Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted April 3, 2023 Share Posted April 3, 2023 (edited) Why not use the webwalker? Pretty sure it can solve the whole stronghold with 1 line of code Only thing you might wanna do is break the webwalking when you need to eat and continue after Also code like this: Timing.waitCondition(() -> getWidgets().get(579, 17).isVisible(),30000); Can cause a lot of errors. Make sure to null check a widget before checking if it's visible. Also it's a lot better to not use any widgets IDs as they can change, use widgetsContainingtext instead Edited April 3, 2023 by Khaleesi Quote Link to comment Share on other sites More sharing options...
Alakazizam Posted April 3, 2023 Share Posted April 3, 2023 (edited) You could set areas before and after each door. if in the area before the door, click on the door. if in the area after the door run to the next area before the next door. before that have it check if in dialogue and if so start a function to handle dialogue. if not in dialogue do the moving around. This is a sample from my HandleDialogue function I made for a quest script. public int onLoop() throws InterruptedException { if (getDialogues().inDialogue()) { HandleDialogue(); } else { //move from area to area and click doors } return 602; } void HandleDialogue() throws InterruptedException { if (getDialogues().isPendingContinuation()) { if (getDialogues().clickContinue()) {sleep(random(200,600));} } else if (getDialogues().isPendingOption()) { if (getDialogues().selectOption("Yes.")) {sleep(random(400,3500));} else if (getDialogues().selectOption("I wanted to use your anvils.")) {sleep(random(400,3500));} else if (getDialogues().selectOption("No, he doesn't look fat")) {sleep(random(400,3500));} else if (getDialogues().selectOption("Do you want me to pick an armour colour for you?")) {sleep(random(400,3500));} else if (getDialogues().selectOption("What about a different colour?")) {sleep(random(400,3500));} else if (getDialogues().selectOption("I have some orange armour here.")) {sleep(random(400,3500));} } } Not sure whats going on with the spacing up there lol Edited April 3, 2023 by Alakazizam Quote Link to comment Share on other sites More sharing options...
Jueix Posted April 3, 2023 Author Share Posted April 3, 2023 4 hours ago, Khaleesi said: Why not use the webwalker? Pretty sure it can solve the whole stronghold with 1 line of code Only thing you might wanna do is break the webwalking when you need to eat and continue after Also code like this: Timing.waitCondition(() -> getWidgets().get(579, 17).isVisible(),30000); Can cause a lot of errors. Make sure to null check a widget before checking if it's visible. Also it's a lot better to not use any widgets IDs as they can change, use widgetsContainingtext instead I did try web walking in the stronghold but it doesn't seem to work for me and I don't know why. Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted April 3, 2023 Share Posted April 3, 2023 2 hours ago, Jueix said: I did try web walking in the stronghold but it doesn't seem to work for me and I don't know why. Check what doesn't work and just report back to the devs ^^ Quote Link to comment Share on other sites More sharing options...