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

Question How to use a SpriteItem on a GameObject

Discussion in 'Developer Support' started by jukkie, Jun 14, 2018.

  1. jukkie

    Joined:
    Apr 8, 2018
    Messages:
    44
    Likes Received:
    6
    I'm trying to use air runes on an altar but the bot clicks on the air runes and doesn't use them on the altar.

    Code (Text):
    1. import com.runemate.game.api.hybrid.entities.GameObject;
    2. import com.runemate.game.api.hybrid.local.hud.interfaces.SpriteItem;
    3. public class Test extends LoopingBot {
    4.     GameObject altar;
    5.     SpriteItem air_rune;
    6.     public static boolean used = false;
    7.     @Override
    8.     public void onStart(String... args){
    9.         setLoopDelay(400,800);
    10.     }
    11.     @Override
    12.     public void onLoop(){
    13.         air_rune = Inventory.newQuery().names("Air rune").results().first();
    14.         altar = GameObjects.newQuery().names("Altar").results().nearest();
    15.         if(air_rune!=null && used == false){
    16.             air_rune.interact("Use");
    17.             used = true;
    18.         } else if(altar!=null){
    19.             air_rune.interact("Use", air_rune.getDefinition().getName() + " -> " + altar);
    20.             used = false;
    21.         }
    22.     }
    23. }
     
  2. CuppaJava

    CuppaJava cuppa.drink(java);

    Joined:
    Mar 13, 2018
    Messages:
    6,117
    Likes Received:
    1,374
  3. lumb taxi

    Joined:
    Nov 24, 2017
    Messages:
    8
    Likes Received:
    1
    Code (Text):
    1. airRune = Inventory.newQuery().names("Air rune").results().first();
    2.         if(airRune != null) {
    3.             if(airRune.interact("Use","Earth rune")) {
    4.                 Execution.delayUntil(()->Inventory.getSelectedItem() != null,1000,1500);
    5.                 altar = GameObjects.newQuery().names("Altar").results().first();
    6.                 if(altar != null) {
    7.                     if(altar.interact("Use", airRune.getDefinition().getName() + " -> " + altar.getDefinition().getName())) {
    8.                         Execution.delayUntil(()->Inventory.newQuery().names("Pure essence").results().size() == 0,750,1050);
    9.                         getLogger().debug("....");
    10.                     }
    11.                     else {
    12.                         getLogger().debug("Failed to interact with altar..."); //Edited after CuppaJava's comment
    13.                     }
    14.                 }
    15.                 else {
    16.                     getLogger().debug("Couldnt find altar");
    17.                 }
    18.             }
    19.             else {
    20.                 getLogger().debug("Failed to interact with rune...");
    21.             }
    22.         }
    23.         else {
    24.             getLogger().debug("Couldn't find air rune");
    25.         }
     
    #3 lumb taxi, Jun 23, 2018
    Last edited: Jun 23, 2018
  4. CuppaJava

    CuppaJava cuppa.drink(java);

    Joined:
    Mar 13, 2018
    Messages:
    6,117
    Likes Received:
    1,374
    Just for the record, the logs aren't accurate. For example, line 7:
    Code (Text):
    1. altar.interact("Use", airRune.getDefinition().getName() + " -> " + altar.getDefinition().getName())
    If this interact() returns false, that doesn't (necessarily) mean it was misclicked, it could also mean the action wasn't totally completed. Eg. interact() could return false if the mouse was still moving towards the altar but not yet completed moving/clcking before that specific bot loop was over. This is so that the bot knows to continue attempting to interact() next iteration of the bot loop.
     
    lumb taxi likes this.
  5. lumb taxi

    Joined:
    Nov 24, 2017
    Messages:
    8
    Likes Received:
    1
    Ahh I didn't know that, thanks for the input.
     
    CuppaJava likes this.

Share This Page

Loading...