Question Noob question

Discussion in 'Developer Support' started by jst94, May 31, 2016.

  1. Hey,
    So i just started learning to understand the code and make my own script bot.
    What does it do now? Withdraws the essence from the bank and then runs to the path. After 2 tiles it runs back and is doing the banking thing again. What am i doing wrong?

    Code (Text):
    1. package com.jst94.aircrafter;
    2.  
    3.  
    4. import com.runemate.game.api.hybrid.entities.GameObject;
    5. import com.runemate.game.api.hybrid.entities.Player;
    6. import com.runemate.game.api.hybrid.local.hud.interfaces.Bank;
    7. import com.runemate.game.api.hybrid.local.hud.interfaces.Inventory;
    8. import com.runemate.game.api.hybrid.location.Area;
    9. import com.runemate.game.api.hybrid.location.Coordinate;
    10. import com.runemate.game.api.hybrid.location.navigation.Traversal;
    11. import com.runemate.game.api.hybrid.location.navigation.basic.BresenhamPath;
    12. import com.runemate.game.api.hybrid.location.navigation.web.WebPath;
    13. import com.runemate.game.api.hybrid.region.GameObjects;
    14. import com.runemate.game.api.hybrid.region.Players;
    15. import com.runemate.game.api.script.Execution;
    16. import com.runemate.game.api.script.framework.LoopingScript;
    17. import com.runemate.game.api.script.framework.listeners.InventoryListener;
    18.  
    19.  
    20.  
    21. /**
    22. * Created by Admin on 5/31/2016.
    23. */
    24. public class JstAirCrafter extends LoopingScript implements InventoryListener {
    25.  
    26.     private final static Player player = Players.getLocal();
    27.     private final static Area bankarea = new Area.Rectangular(new Coordinate(3012, 3358, 0), new Coordinate(3014, 3355, 0));
    28.     private final static Area altararea = new Area.Rectangular(new Coordinate(2988, 3292, 0), new Coordinate(2983, 3290, 0));
    29.  
    30.     @Override
    31.     public void onStart(String... args) {
    32.         setLoopDelay(400, 500);
    33.         getEventDispatcher().addListener(this);
    34.     }
    35.  
    36.  
    37.     public void onLoop() {
    38.         setLoopDelay(400, 500);
    39.         if (Inventory.isEmpty() && bankarea.contains(player)) ; //Withdraws essence from the bank + check for bank
    40.         if (!Bank.isOpen()) {
    41.             Bank.open();
    42.             Execution.delay(200, 300);
    43.         } else {
    44.             Bank.withdraw(1436, 28);
    45.             Execution.delay(200, 300);
    46.  
    47.         }
    48.  
    49.  
    50.      if (Inventory.isFull() && !altararea.contains(player)) ;
    51.         final WebPath altarpath = Traversal.getDefaultWeb().getPathBuilder().buildTo(altararea.getCenter()); // builds a path to the altar
    52.  
    53.         final BresenhamPath failaltarpath = BresenhamPath.buildTo(altararea.getCenter()); //Builds a fail path to the altararea
    54.  
    55.         if (altarpath != null) {
    56.             altarpath.step();
    57.         } else if (failaltarpath != null) {
    58.             failaltarpath.step();
    59.         }
    60.  
    61.         GameObject entrance = GameObjects.getLoaded(1).nearestTo(player); //Checks if the altar is loaded on the game
    62.  
    63.         if (altararea.contains(player)) ;
    64.         {
    65.             if (entrance != null && entrance.isValid()) {
    66.                 entrance.interact("Enter Mysterious ruins");
    67.  
    68.             }
    69.  
    70.  
    71.         }
    72.     }
    73. }
    74.  
    75.  
    76.  
    77.  
    Thanks!
     
  2. Change:
    Code (Text):
    1. if (Inventory.isEmpty() && bankarea.contains(player)) ; //Withdraws essence from the bank + check for bank
    2.         if (!Bank.isOpen()) {
    3.             Bank.open();
    4.             Execution.delay(200, 300);
    5.         } else {
    6.             Bank.withdraw(1436, 28);
    7.             Execution.delay(200, 300);
    8.         }
    9.  
    To:
    Code (Text):
    1. if (Inventory.isEmpty() && bankarea.contains(player)){
    2. //Withdraws essence from the bank + check for bank
    3.         if (!Bank.isOpen()) {
    4.             Bank.open();
    5.             Execution.delay(200, 300);
    6.         } else {
    7.             Bank.withdraw(1436, 28);
    8.             Execution.delay(200, 300);
    9.         }
    10. }
    11.  
    --- Double Post Merged, May 31, 2016, Original Post Date: May 31, 2016 ---
    Also join the RuneMate Slack #development channel :)

    Always people in there willing to help, myself included.
    --- Double Post Merged, May 31, 2016 ---
    Glad you're trying to get involved though, always good to see people trying out something new! Next section of my guide will be incredibly useful to you (as I see you're trying to use LoopingScript).
     
  3. Hey thanks @Party for the quick respond.
    Will join the dev channel :)

    What it does now after changing the code it keeps running in and out the bank
     
  4. Pretty sure this line is the issue, maybe you intended to have the following code in that if statement? If so then you use brackets, not a semi-colon.
     

Share This Page

Loading...