1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Question Interfaces

Discussion in 'Developer Support' started by SoTa, Oct 28, 2015.

  1. SoTa

    Joined:
    Oct 17, 2015
    Messages:
    11
    Likes Received:
    0
    I'm attempting my first go at a bot(Flax Spinner), but I'm having a little trouble. I've managed to make it open the crafting interface, but I can't for the life of me find out how to make it hit "Spin" in the interface. I've found the correct interface (1371) in the developer kit. I just need to make it click "Spin." I've attached a picture below and I may also need help a little later if I failed on my movement setup. Hopefully not, lol.. Thanks in advance!

    [​IMG]
     
  2. Savior

    Savior Java Warlord

    Joined:
    Nov 17, 2014
    Messages:
    4,906
    Likes Received:
    2,748
    Code (Text):
    1. final InterfaceComponent spinInterface = Interfaces.newQuery().containers(1371).texts("Spin").results().first();
    2. if (spinInterface != null) {
    3.   spinInterface.click(); //interact() if you know the action
    4. }
     
    SoTa likes this.
  3. Scourge

    Joined:
    Jun 7, 2015
    Messages:
    100
    Likes Received:
    16
    If you'd want to make it a bit easier, you could try "Alpha Interface Viewer", same thing as the Interface kit that you seem to be using. But since you are need to click a component on the interface, you would need to define it.
    After you've defined it as whatever you want, it is simply:

    Code (Text):
    1. if (component != null) {
    2. component.click();
    3. }
     
    SoTa likes this.
  4. Defeat3d

    Defeat3d Primate

    Joined:
    Oct 30, 2014
    Messages:
    3,017
    Likes Received:
    1,890
    Won't work... The interface doesn't have a text.

    Try looking for "Spin" in the search bar, it will help you find the correct interface component.
     
    SoTa likes this.
  5. SoTa

    Joined:
    Oct 17, 2015
    Messages:
    11
    Likes Received:
    0
    Thanks y'all!

    I looked for spin, and in interface 1370, it has component 40 with 5 sub-components. I'm pretty sure the 5 sub's are each of the 5 items that can be used on the wheel. (1370, 40, 1) would be the second one in the interface which would be bowstrings. How would I implement that inside Savior's code though?

    final InterfaceComponent spinInterface = Interfaces.newQuery().containers(1371).texts("Spin").results().first();
    if (spinInterface != null) {
    spinInterface.interact("Make 28 Bowstring");
    }

    EDIT: Here's the component contents:

    Index: 1
    Visible: true
    Components: 0
    Bounds: (x=975, y=562, width=240, height=42)
    Text: Spin
    Text Color: (r=39, g=34, b=15)
    Content Type: 0
    Projected Entity: null
    Border Thickness: 0
    Texture Id: -1
    Name (on menu): null
    Actions:
    --- Double Post Merged, Oct 28, 2015, Original Post Date: Oct 28, 2015 ---
    I've made it click by changing the interface to (1370, 40, 1) and using .click(). I just have to make it wait until it's finished lol. It's clicking the wheel right after it starts. xD I think I can fix that though.
     
  6. Defeat3d

    Defeat3d Primate

    Joined:
    Oct 30, 2014
    Messages:
    3,017
    Likes Received:
    1,890
    final InterfaceComponent spinInterface = Interfaces.newQuery().texts("Spin").visible().results().first();

    Don't try to interact with it, it has no actions, use click like you mentioned.
    --- Double Post Merged, Oct 28, 2015, Original Post Date: Oct 28, 2015 ---
    Using IDs is discouraged, because they can be changed by Jagex fairly easily without having it impact the game.
     
    SoTa likes this.
  7. SoTa

    Joined:
    Oct 17, 2015
    Messages:
    11
    Likes Received:
    0
    I don't understand why this isn't working :/. It continues to click the wheel after it's started. This is my code:

    Code (Text):
    1.  
    2. private boolean isIdle() {
    3. return player.getAnimationId() == -1 && !player.isMoving();
    4. }
    5. @Override
    6. public void onLoop() {
    7. GameObject spinningwheel = GameObjects.getLoaded(36970).nearestTo(player);
    8. if (Inventory.contains("Flax") && spinArea.contains(player) && isIdle()) {
    9. spinningwheel.interact("Spin");
    10. final InterfaceComponent spinInterface = Interfaces.newQuery().containers(1370, 40, 1).texts("Spin").results().first();
    11. if (spinInterface != null) {
    12. spinInterface.click();
    13. }
    14.  
    --- Double Post Merged, Oct 28, 2015, Original Post Date: Oct 28, 2015 ---
    Ahh, didn't think of that.. I'll do away with using id's then! Thanks!
    --- Double Post Merged, Oct 28, 2015 ---
    I did away with all the ID's I was using and also added an execution delay, that part works. Sadly enough, moving between the two floors doesn't, but I'm going to try to figure this out. Thanks for your help thus far!
     
  8. Savior

    Savior Java Warlord

    Joined:
    Nov 17, 2014
    Messages:
    4,906
    Likes Received:
    2,748
    Just wrote that as an example to generally find interfaces
     
  9. SoTa

    Joined:
    Oct 17, 2015
    Messages:
    11
    Likes Received:
    0
    Okay, my baby is crying so I have to feed her and stuff. I'll be back later! I'm having movement issues still though. I know I probably have this set up wrong, but here's my code:

    Code (Text):
    1.  
    2. private final static Area spinArea = new Area.Rectangular(new Coordinate(3212, 3212, 1), new Coordinate(3208, 3216, 1));
    3.  
    4. } else if (Inventory.contains("Flax") && !spinArea.contains(player)) {
    5. final WebPath spinPath = Traversal.getDefaultWeb().getPathBuilder().buildTo(spinArea.getRandomCoordinate());
    6. final BresenhamPath failspinPath = BresenhamPath.buildTo(spinArea.getRandomCoordinate());
    7. if (spinPath != null) {
    8. spinPath.step();
    9. } else if (failspinPath != null) {
    10. failspinPath.step();
    11. }
    12.  
    I'm attempting to go back and forth between the 3rd story of lumbridge castle and the second. What am I doing wrong? Does it not build the path over multiple stories?
     
  10. Defeat3d

    Defeat3d Primate

    Joined:
    Oct 30, 2014
    Messages:
    3,017
    Likes Received:
    1,890
    Lumbridge castle is not included in the default web.
     
  11. youramazingames

    Joined:
    Oct 24, 2015
    Messages:
    79
    Likes Received:
    13
    If you still not got it worked then do this:

    Code (Text):
    1. private static boolean spin() {
    2.         if (isProductScreenOpen()) {
    3.             Execution.delay(200, 700);
    4.             Keyboard.typeKey(" ");
    5.             return Execution.delayUntil(() -> !isProductScreenOpen(), 5000);
    6.         }
    7.         return false;
    8.     }
    Then just put something in that checks if the screen is open then add the spin() in or something!
     
  12. Scourge

    Joined:
    Jun 7, 2015
    Messages:
    100
    Likes Received:
    16
    Under your spinInterface.click(); ->

    Code (Text):
    1. spinInterface.click();
    2. Execution.delayUntil(()-> !Inventory.containsAnyOf("Flax");
     
  13. Defeat3d

    Defeat3d Primate

    Joined:
    Oct 30, 2014
    Messages:
    3,017
    Likes Received:
    1,890
    Very unsafe...
     
  14. Scourge

    Joined:
    Jun 7, 2015
    Messages:
    100
    Likes Received:
    16
    really? can you explain why? i figured it would be ok :(
     
  15. Defeat3d

    Defeat3d Primate

    Joined:
    Oct 30, 2014
    Messages:
    3,017
    Likes Received:
    1,890
    Because if you for some reason don't get rid of all the flax at once, for example when you level up or you disconnect, the bot will be stuck waiting forever.
     
  16. SoTa

    Joined:
    Oct 17, 2015
    Messages:
    11
    Likes Received:
    0
    Finally got baby settled. Since web walking doesn't work in Lumbridge castle, any recommendations on how I should get the bot to between the 2nd and 3rd floor?
    --- Double Post Merged, Oct 28, 2015, Original Post Date: Oct 28, 2015 ---
    Also, I'm just going to use: Execution.delay(50000, 50500);. It gives it an extra 2 to 2 1/2 seconds after the flax is done. Takes 48 seconds for a full inventory.
     
  17. Defeat3d

    Defeat3d Primate

    Joined:
    Oct 30, 2014
    Messages:
    3,017
    Likes Received:
    1,890
    I recommend using something like this:

    Code (Text):
    1. final Player local = Players.getLocal();
    2. Execution.delayUntil(() -> !Inventory.contains("Flax"), () -> local != null && local.getAnimationId() != -1, 3000);
     
  18. pkingd3vil

    Joined:
    Oct 1, 2015
    Messages:
    39
    Likes Received:
    5
    Does the 3000 vary the delay by 3 seconds?
     
  19. Scourge

    Joined:
    Jun 7, 2015
    Messages:
    100
    Likes Received:
    16
    ah i see, makes sense.
    yee
     
  20. SoTa

    Joined:
    Oct 17, 2015
    Messages:
    11
    Likes Received:
    0
    Well, it's running. I'm still cleaning up some bugs in it. It somehow managed to get to the ground level and freaked out and stood there frozen lol. Fixed that. It's on 5 runs thus far with no issues though! Thanks everyone for y'alls help! :)
     

Share This Page

Loading...