Keyboard interaction

Discussion in 'Developer Support' started by Geashaw, Jan 31, 2015.

  1. My first question is why are you using the numbers 49 and 50 instead of using KeyEvent.VK_KEY.
    Now, as you can see it presses the second one after the first which means it is releasing it properly to begin with (not an api bug then).
    Also, show me the code that's calling each of those methods so I can try and see where your logic error is.
     
  2. This is my current code;

    Code (Text):
    1.  
    2. package com.runemate.geashawscripts.banana;//Imports are all the classes that we are going to use methods fromimport com.runemate.game.api.client.paint.PaintListener;import com.runemate.game.api.hybrid.RuneScape;import com.runemate.game.api.hybrid.entities.Actor;import com.runemate.game.api.hybrid.entities.GameObject;import com.runemate.game.api.hybrid.entities.Npc;import com.runemate.game.api.hybrid.entities.Player;import com.runemate.game.api.hybrid.input.Keyboard;import com.runemate.game.api.hybrid.local.Camera;import com.runemate.game.api.hybrid.local.hud.interfaces.Bank;import com.runemate.game.api.hybrid.local.hud.interfaces.InterfaceComponent;import com.runemate.game.api.hybrid.local.hud.interfaces.Interfaces;import com.runemate.game.api.hybrid.local.hud.interfaces.Inventory;import com.runemate.game.api.hybrid.location.Area;import com.runemate.game.api.hybrid.location.Coordinate;import com.runemate.game.api.hybrid.location.navigation.Path;import com.runemate.game.api.hybrid.location.navigation.Traversal;import com.runemate.game.api.hybrid.region.GameObjects;import com.runemate.game.api.hybrid.region.Npcs;import com.runemate.game.api.hybrid.region.Players;import com.runemate.game.api.hybrid.util.StopWatch;import com.runemate.game.api.rs3.local.hud.interfaces.eoc.ActionBar;import com.runemate.game.api.rs3.local.hud.interfaces.eoc.SlotAction;import com.runemate.game.api.rs3.net.GrandExchange;import com.runemate.game.api.script.Execution;import com.runemate.game.api.script.framework.LoopingScript;import com.runemate.game.api.script.framework.listeners.InventoryListener;import com.runemate.game.api.script.framework.listeners.events.ItemEvent;import java.awt.*;import java.awt.event.KeyEvent;import java.text.NumberFormat;public class bananapicker extends LoopingScript implements PaintListener, InventoryListener {
    3.  
    4. private String status = "Starting up..."; private final StopWatch runtime = new StopWatch(); private final String BANANA = "Banana"; private final String BASKET = "Basket"; private final String FILLED_BASKET = "Bananas (5)"; private final String GLORY = "Amulet of glory"; private int BANANA_COUNT, BANANA_BASKET_PRICE, PROFIT_MADE; final Area KARAMJA_AREA = new Area.Rectangular(new Coordinate(2905, 3154), new Coordinate(2935, 3180, 0)); final Area EDGEVILLE_AREA = new Area.Rectangular(new Coordinate(3084, 3488, 0), new Coordinate(3097, 3499, 0)); final Player player = Players.getLocal(); private Path walkToTree;@Overridepublic void onStart(String... args) {
    5. setLoopDelay(100, 200);getEventDispatcher().addListener(this);BANANA_BASKET_PRICE = GrandExchange.lookup(5416).getPrice();runtime.start();debug("Test.");}
    6.  
    7. @Overridepublic void onLoop() {
    8.  
    9. // Check if the user is logged in.if (RuneScape.isLoggedIn()) {
    10. if (atEdgeville()) {
    11. if (gotFilledBaskets()) {
    12. Npc banker = Npcs.newQuery().names("Banker").results().nearest(); if (banker != null) {
    13. if (banker.isVisible()) {
    14. if (Bank.isOpen()) {
    15. performBankPreset();} else {
    16. openBank();}
    17. } else {
    18. debug("Turning camera to banker");Camera.setPitch(0.234);Camera.turnTo(banker);}
    19. }
    20. } else if (gotAllEmptyBaskets()) {
    21. teleportToKaramja();}
    22. } else if (atKaramja()) {
    23. if (gotFilledBaskets()) {
    24. teleportToEdgeville();} else if (canPutBananasInBasket()) {
    25. putBananasIntoBasket();} else if (canPickBananasFromTree()) {
    26. pickBananasFromTree();}
    27. }
    28. }
    29. }
    30.  
    31. /** * Teleport to Edgeville. */private boolean teleportToEdgeville() {
    32. SlotAction action = ActionBar.getFirstAction(GLORY); if (action != null) {
    33. status = "Activating glory."; if (action.activate()) {
    34. if (teleportToEdgevilleOptionIsVisible()) {
    35. // A little extra delay.status = "Selecting Edgeville teleport.";debug("Typing key 49"); if (Keyboard.pressKey(KeyEvent.VK_1)) {
    36. Keyboard.releaseKey(KeyEvent.VK_1);Execution.delayUntil(() -> !teleportToEdgevilleOptionIsVisible(), 3000, 4000); return true;}
    37. } else {
    38. Execution.delayUntil(() -> teleportToEdgevilleOptionIsVisible(), 1000, 1500);}
    39. }
    40. }
    41.  
    42. return false;}
    43.  
    44. /** * Teleport to Karamja. */private boolean teleportToKaramja() {
    45. SlotAction action = ActionBar.getFirstAction(GLORY); if (action != null) {
    46. status = "Activating glory."; if (action.activate()) {
    47. if (teleportToKaramjaOptionIsVisible()) {
    48. // A little extra delay.status = "Selecting Karamja teleport.";debug("Typing key 50"); if (Keyboard.pressKey(KeyEvent.VK_2)) {
    49. Keyboard.releaseKey(KeyEvent.VK_2);Execution.delayUntil(() -> !teleportToKaramjaOptionIsVisible(), 3000, 4000); return true;}
    50. } else {
    51. Execution.delayUntil(() -> teleportToKaramjaOptionIsVisible(), 1000, 1500);}
    52. }
    53. }
    54.  
    55. return false;}
    56.  
    57.  
    58. /** * Perform quick banking with a bank preset. */private boolean performBankPreset() {
    59. InterfaceComponent component = Interfaces.getAt(762, 41); if (component != null && component.isVisible()) {
    60. if (component.click()) {
    61. status = "Performing bank preset";debug("Performing bank preset");Execution.delayUntil(() -> !Bank.isOpen(), 0, 1000); return true;}
    62. }
    63.  
    64. return false;}
    65.  
    66. /** * Open the bank. */private boolean openBank() {
    67. status = "Opening the bank.";debug("Opening the bank"); if (Bank.open()) {
    68. if (!Bank.isOpen()) {
    69. Execution.delayUntil(() -> Bank.isOpen(), 500); return true;}
    70. }
    71. return false;}
    72.  
    73. /** * Pick bananas from a tree. */private boolean pickBananasFromTree() {
    74. GameObject tree = GameObjects.newQuery().names("Banana Tree").actions("Pick").results().nearest(); if (tree != null) {
    75. if (tree.distanceTo(player) > 7) {
    76. debug("Tree is further than 7 steps");status = "Tree is further than 7 steps";walkToTree = Traversal.getDefaultWeb().getPathBuilder().buildTo(tree); if (walkToTree != null) {
    77. status = "Walking to tree";walkToTree.step(true);} else {
    78. debug("Can't walk to tree...");status = "Can't walk to tree...";}
    79. } else {
    80. if (tree.isVisible()) {
    81. if (!isBusy(player)) {
    82. if (Camera.getPitch() < 0.35) {
    83. Camera.setPitch(0.60, 0.65);} else {
    84. status = "Picking bananas."; return tree.interact("Pick");}
    85. }
    86. } else {
    87. debug("Turning camera to tree");Camera.turnTo(tree);}
    88. }
    89. }
    90.  
    91. return false;}
    92.  
    93. /** * Put banana into an empty basket using the action bar. */private boolean putBananasIntoBasket() {
    94. SlotAction action = ActionBar.getFirstAction("Basket"); if (action != null) {
    95. status = "Putting bananas into basket."; if (Keyboard.typeKey(action.getSlot().getKeyBind())) {
    96. if (gotBananas()) {
    97. Execution.delayUntil(() -> !gotBananas(), 0, 500); return true;}
    98. }
    99. }
    100.  
    101. return false;}
    102.  
    103. /** * Check if whether the player is at Edgeville or not. */private boolean atEdgeville() {
    104. return EDGEVILLE_AREA.contains(player);}
    105.  
    106. /** * Check if the player is at Karamja or not. */private boolean atKaramja() {
    107. return KARAMJA_AREA.contains(player);}
    108.  
    109. /** * Check if the player has at least 5 bananas in inventory. */private boolean gotBananas() {
    110. return (Inventory.contains(BANANA) && Inventory.getQuantity(BANANA) >= 5);}
    111.  
    112. /** * Check if the player has at least one empty basket */private boolean gotEmptyBaskets() {
    113. return (Inventory.contains(BASKET) && Inventory.getQuantity(BASKET) >= 1);}
    114.  
    115. /** * Check if the player has at least 23 empty baskets */private boolean gotAllEmptyBaskets() {
    116. return (Inventory.contains(BASKET) && Inventory.getQuantity(BASKET) >= 23);}
    117.  
    118. /** * Check if the the player has at least 23 filled baskets. */private boolean gotFilledBaskets() {
    119. return (Inventory.contains(FILLED_BASKET) && Inventory.getQuantity(FILLED_BASKET) >= 23);}
    120.  
    121. /** * Check if the player can pick bananas from a tree. */private boolean canPickBananasFromTree() {
    122. return !Inventory.isFull() && !gotBananas();}
    123.  
    124. /** * Check if the player can put bananas into an empty basket. */private boolean canPutBananasInBasket() {
    125. return gotBananas() && gotEmptyBaskets();}
    126.  
    127. /** * Check if the teleport interface is visible. */private boolean teleportToEdgevilleOptionIsVisible() {
    128. InterfaceComponent component = Interfaces.newQuery().texts("Edgeville.").visible().results().first(); return (component != null && component.isValid());}
    129.  
    130.  
    131. private boolean teleportToKaramjaOptionIsVisible() {
    132. InterfaceComponent component = Interfaces.newQuery().texts("Karamja.").visible().results().first(); return (component != null && component.isValid());}
    133.  
    134. private boolean isBusy(final Actor player) {
    135. return player.isMoving() || player.getAnimationId() != -1;}
    136.  
    137. /** * Turn amount gained into amount gained per hour. * * @param amount The amount of experience. * @param elapsed The elapsed time. * @return Returns the int amount per hour. */public int getHourly(final int amount, final long elapsed) {
    138. return (int) (amount * 3600000.0D / elapsed);}
    139.  
    140. /** * Method to format thousands decimal. * * @param i The integer to format. * @return Returns the integer as formatted number. */protected String formatNumber(int i) {
    141. return NumberFormat.getIntegerInstance().format(i);}
    142.  
    143. /** * Helper method used to replace System.out.println(text); * * @param text The text to send to the console. */private void debug(String text) {
    144. System.out.println(text);}
    145.  
    146. /** * Count items that are added to inventory. [email protected] void onItemAdded(ItemEvent arg0) {
    147. if (arg0.getItem().getDefinition().getName().equals("Banana")) {
    148. BANANA_COUNT++;}
    149. }
    150.  
    151. /* * This is where we put everything that we want to draw to the screen. * Graphics2D is the class that contains all the paint methods. [email protected] void onPaint(Graphics2D g) {
    152. int x = 5, y = 15;PROFIT_MADE = BANANA_COUNT / 5 * BANANA_BASKET_PRICE;g.drawString("Version " + getMetaData().getVersion(), x, y);g.drawString("Run time: " + runtime.getRuntimeAsString(), x, y + 15);g.drawString("Status: " + status, x, y + 30);g.drawString("Bananas: " + formatNumber(BANANA_COUNT) + " (" + formatNumber(getHourly(BANANA_COUNT, runtime.getRuntime())) + ")", x, y + 45);g.drawString("Baskets: " + formatNumber(BANANA_COUNT / 5) + " (" + formatNumber(getHourly(BANANA_COUNT /5, runtime.getRuntime())) + ")", x, y + 60);g.drawString("Profits: " + formatNumber(PROFIT_MADE) + " (" + formatNumber(getHourly(PROFIT_MADE, runtime.getRuntime())) + ")", x, y + 75);}
    153.  
    154. @Overridepublic void onPause() {
    155. runtime.stop();}
    156.  
    157. @Overridepublic void onResume() {
    158. runtime.start();}
    159.  
    160. }
     
  3. Can you please fix your formatting?
     
  4. Would this work? @Cloud

    Code (Text):
    1.  
    2. package com.runemate.geashawscripts.banana; //Imports are all the classes that we are going to use methods fromimport com.runemate.game.api.client.paint.PaintListener;import com.runemate.game.api.hybrid.RuneScape;import com.runemate.game.api.hybrid.entities.Actor;import com.runemate.game.api.hybrid.entities.GameObject;import com.runemate.game.api.hybrid.entities.Npc;import com.runemate.game.api.hybrid.entities.Player;import com.runemate.game.api.hybrid.input.Keyboard;import com.runemate.game.api.hybrid.local.Camera;import com.runemate.game.api.hybrid.local.hud.interfaces.Bank;import com.runemate.game.api.hybrid.local.hud.interfaces.InterfaceComponent;import com.runemate.game.api.hybrid.local.hud.interfaces.Interfaces;import com.runemate.game.api.hybrid.local.hud.interfaces.Inventory;import com.runemate.game.api.hybrid.location.Area;import com.runemate.game.api.hybrid.location.Coordinate;import com.runemate.game.api.hybrid.location.navigation.Path;import com.runemate.game.api.hybrid.location.navigation.Traversal;import com.runemate.game.api.hybrid.region.GameObjects;import com.runemate.game.api.hybrid.region.Npcs;import com.runemate.game.api.hybrid.region.Players;import com.runemate.game.api.hybrid.util.StopWatch;import com.runemate.game.api.rs3.local.hud.interfaces.eoc.ActionBar;import com.runemate.game.api.rs3.local.hud.interfaces.eoc.SlotAction;import com.runemate.game.api.rs3.net.GrandExchange;import com.runemate.game.api.script.Execution;import com.runemate.game.api.script.framework.LoopingScript;import com.runemate.game.api.script.framework.listeners.InventoryListener;import com.runemate.game.api.script.framework.listeners.events.ItemEvent;import java.awt.*;import java.awt.event.KeyEvent;import java.text.NumberFormat;public class bananapicker extends LoopingScript implements PaintListener, InventoryListener {
    3.  
    4. private String status = "Starting up...";
    5. private final StopWatch runtime = new StopWatch();
    6. private final String BANANA = "Banana";
    7. private final String BASKET = "Basket";
    8. private final String FILLED_BASKET = "Bananas (5)";
    9. private final String GLORY = "Amulet of glory";
    10. private int BANANA_COUNT, BANANA_BASKET_PRICE, PROFIT_MADE;
    11. final Area KARAMJA_AREA = new Area.Rectangular(new Coordinate(2905, 3154), new Coordinate(2935, 3180, 0));
    12. final Area EDGEVILLE_AREA = new Area.Rectangular(new Coordinate(3084, 3488, 0), new Coordinate(3097, 3499, 0));
    13. final Player player = Players.getLocal();
    14. private Path walkToTree;@Overridepublic void onStart(String...args) {
    15.     setLoopDelay(100, 200);
    16.     getEventDispatcher().addListener(this);
    17.     BANANA_BASKET_PRICE = GrandExchange.lookup(5416).getPrice();
    18.     runtime.start();
    19.     debug("Test.");
    20. }
    21.  
    22. @Overridepublic void onLoop() {
    23.  
    24.     // Check if the user is logged in.if (RuneScape.isLoggedIn()) {
    25.     if (atEdgeville()) {
    26.         if (gotFilledBaskets()) {
    27.             Npc banker = Npcs.newQuery().names("Banker").results().nearest();
    28.             if (banker != null) {
    29.                 if (banker.isVisible()) {
    30.                     if (Bank.isOpen()) {
    31.                         performBankPreset();
    32.                     } else {
    33.                         openBank();
    34.                     }
    35.                 } else {
    36.                     debug("Turning camera to banker");
    37.                     Camera.setPitch(0.234);
    38.                     Camera.turnTo(banker);
    39.                 }
    40.             }
    41.         } else if (gotAllEmptyBaskets()) {
    42.             teleportToKaramja();
    43.         }
    44.     } else if (atKaramja()) {
    45.         if (gotFilledBaskets()) {
    46.             teleportToEdgeville();
    47.         } else if (canPutBananasInBasket()) {
    48.             putBananasIntoBasket();
    49.         } else if (canPickBananasFromTree()) {
    50.             pickBananasFromTree();
    51.         }
    52.     }
    53. }
    54. }
    55.  
    56. /** * Teleport to Edgeville. */
    57. private boolean teleportToEdgeville() {
    58.     SlotAction action = ActionBar.getFirstAction(GLORY);
    59.     if (action != null) {
    60.         status = "Activating glory.";
    61.         if (action.activate()) {
    62.             if (teleportToEdgevilleOptionIsVisible()) {
    63.                 // A little extra delay.status = "Selecting Edgeville teleport.";debug("Typing key 49"); if (Keyboard.pressKey(KeyEvent.VK_1)) {
    64.                 Keyboard.releaseKey(KeyEvent.VK_1);
    65.                 Execution.delayUntil(() - > !teleportToEdgevilleOptionIsVisible(), 3000, 4000);
    66.                 return true;
    67.             }
    68.         } else {
    69.             Execution.delayUntil(() - > teleportToEdgevilleOptionIsVisible(), 1000, 1500);
    70.         }
    71.     }
    72. }
    73.  
    74. return false;
    75. }
    76.  
    77. /** * Teleport to Karamja. */
    78. private boolean teleportToKaramja() {
    79.     SlotAction action = ActionBar.getFirstAction(GLORY);
    80.     if (action != null) {
    81.         status = "Activating glory.";
    82.         if (action.activate()) {
    83.             if (teleportToKaramjaOptionIsVisible()) {
    84.                 // A little extra delay.status = "Selecting Karamja teleport.";debug("Typing key 50"); if (Keyboard.pressKey(KeyEvent.VK_2)) {
    85.                 Keyboard.releaseKey(KeyEvent.VK_2);
    86.                 Execution.delayUntil(() - > !teleportToKaramjaOptionIsVisible(), 3000, 4000);
    87.                 return true;
    88.             }
    89.         } else {
    90.             Execution.delayUntil(() - > teleportToKaramjaOptionIsVisible(), 1000, 1500);
    91.         }
    92.     }
    93. }
    94.  
    95. return false;
    96. }
    97.  
    98.  
    99. /** * Perform quick banking with a bank preset. */
    100. private boolean performBankPreset() {
    101.     InterfaceComponent component = Interfaces.getAt(762, 41);
    102.     if (component != null && component.isVisible()) {
    103.         if (component.click()) {
    104.             status = "Performing bank preset";
    105.             debug("Performing bank preset");
    106.             Execution.delayUntil(() - > !Bank.isOpen(), 0, 1000);
    107.             return true;
    108.         }
    109.     }
    110.  
    111.     return false;
    112. }
    113.  
    114. /** * Open the bank. */
    115. private boolean openBank() {
    116.     status = "Opening the bank.";
    117.     debug("Opening the bank");
    118.     if (Bank.open()) {
    119.         if (!Bank.isOpen()) {
    120.             Execution.delayUntil(() - > Bank.isOpen(), 500);
    121.             return true;
    122.         }
    123.     }
    124.     return false;
    125. }
    126.  
    127. /** * Pick bananas from a tree. */
    128. private boolean pickBananasFromTree() {
    129.     GameObject tree = GameObjects.newQuery().names("Banana Tree").actions("Pick").results().nearest();
    130.     if (tree != null) {
    131.         if (tree.distanceTo(player) > 7) {
    132.             debug("Tree is further than 7 steps");
    133.             status = "Tree is further than 7 steps";
    134.             walkToTree = Traversal.getDefaultWeb().getPathBuilder().buildTo(tree);
    135.             if (walkToTree != null) {
    136.                 status = "Walking to tree";
    137.                 walkToTree.step(true);
    138.             } else {
    139.                 debug("Can't walk to tree...");
    140.                 status = "Can't walk to tree...";
    141.             }
    142.         } else {
    143.             if (tree.isVisible()) {
    144.                 if (!isBusy(player)) {
    145.                     if (Camera.getPitch() < 0.35) {
    146.                         Camera.setPitch(0.60, 0.65);
    147.                     } else {
    148.                         status = "Picking bananas.";
    149.                         return tree.interact("Pick");
    150.                     }
    151.                 }
    152.             } else {
    153.                 debug("Turning camera to tree");
    154.                 Camera.turnTo(tree);
    155.             }
    156.         }
    157.     }
    158.  
    159.     return false;
    160. }
    161.  
    162. /** * Put banana into an empty basket using the action bar. */
    163. private boolean putBananasIntoBasket() {
    164.     SlotAction action = ActionBar.getFirstAction("Basket");
    165.     if (action != null) {
    166.         status = "Putting bananas into basket.";
    167.         if (Keyboard.typeKey(action.getSlot().getKeyBind())) {
    168.             if (gotBananas()) {
    169.                 Execution.delayUntil(() - > !gotBananas(), 0, 500);
    170.                 return true;
    171.             }
    172.         }
    173.     }
    174.  
    175.     return false;
    176. }
    177.  
    178. /** * Check if whether the player is at Edgeville or not. */
    179. private boolean atEdgeville() {
    180.     return EDGEVILLE_AREA.contains(player);
    181. }
    182.  
    183. /** * Check if the player is at Karamja or not. */
    184. private boolean atKaramja() {
    185.     return KARAMJA_AREA.contains(player);
    186. }
    187.  
    188. /** * Check if the player has at least 5 bananas in inventory. */
    189. private boolean gotBananas() {
    190.     return (Inventory.contains(BANANA) && Inventory.getQuantity(BANANA) >= 5);
    191. }
    192.  
    193. /** * Check if the player has at least one empty basket */
    194. private boolean gotEmptyBaskets() {
    195.     return (Inventory.contains(BASKET) && Inventory.getQuantity(BASKET) >= 1);
    196. }
    197.  
    198. /** * Check if the player has at least 23 empty baskets */
    199. private boolean gotAllEmptyBaskets() {
    200.     return (Inventory.contains(BASKET) && Inventory.getQuantity(BASKET) >= 23);
    201. }
    202.  
    203. /** * Check if the the player has at least 23 filled baskets. */
    204. private boolean gotFilledBaskets() {
    205.     return (Inventory.contains(FILLED_BASKET) && Inventory.getQuantity(FILLED_BASKET) >= 23);
    206. }
    207.  
    208. /** * Check if the player can pick bananas from a tree. */
    209. private boolean canPickBananasFromTree() {
    210.     return !Inventory.isFull() && !gotBananas();
    211. }
    212.  
    213. /** * Check if the player can put bananas into an empty basket. */
    214. private boolean canPutBananasInBasket() {
    215.     return gotBananas() && gotEmptyBaskets();
    216. }
    217.  
    218. /** * Check if the teleport interface is visible. */
    219. private boolean teleportToEdgevilleOptionIsVisible() {
    220.     InterfaceComponent component = Interfaces.newQuery().texts("Edgeville.").visible().results().first();
    221.     return (component != null && component.isValid());
    222. }
    223.  
    224.  
    225. private boolean teleportToKaramjaOptionIsVisible() {
    226.     InterfaceComponent component = Interfaces.newQuery().texts("Karamja.").visible().results().first();
    227.     return (component != null && component.isValid());
    228. }
    229.  
    230. private boolean isBusy(final Actor player) {
    231.     return player.isMoving() || player.getAnimationId() != -1;
    232. }
    233.  
    234. /** * Turn amount gained into amount gained per hour. * * @param amount The amount of experience. * @param elapsed The elapsed time. * @return Returns the int amount per hour. */
    235. public int getHourly(final int amount, final long elapsed) {
    236.     return (int)(amount * 3600000.0D / elapsed);
    237. }
    238.  
    239. /** * Method to format thousands decimal. * * @param i The integer to format. * @return Returns the integer as formatted number. */
    240. protected String formatNumber(int i) {
    241.     return NumberFormat.getIntegerInstance().format(i);
    242. }
    243.  
    244. /** * Helper method used to replace System.out.println(text); * * @param text The text to send to the console. */
    245. private void debug(String text) {
    246.     System.out.println(text);
    247. }
    248.  
    249. /** * Count items that are added to inventory. */
    250. @Overridepublic void onItemAdded(ItemEvent arg0) {
    251.     if (arg0.getItem().getDefinition().getName().equals("Banana")) {
    252.         BANANA_COUNT++;
    253.     }
    254. }
    255.  
    256. /* * This is where we put everything that we want to draw to the screen. * Graphics2D is the class that contains all the paint methods. */
    257. @Overridepublic void onPaint(Graphics2D g) {
    258.     int x = 5, y = 15;
    259.     PROFIT_MADE = BANANA_COUNT / 5 * BANANA_BASKET_PRICE;
    260.     g.drawString("Version " + getMetaData().getVersion(), x, y);
    261.     g.drawString("Run time: " + runtime.getRuntimeAsString(), x, y + 15);
    262.     g.drawString("Status: " + status, x, y + 30);
    263.     g.drawString("Bananas: " + formatNumber(BANANA_COUNT) + " (" + formatNumber(getHourly(BANANA_COUNT, runtime.getRuntime())) + ")", x, y + 45);
    264.     g.drawString("Baskets: " + formatNumber(BANANA_COUNT / 5) + " (" + formatNumber(getHourly(BANANA_COUNT / 5, runtime.getRuntime())) + ")", x, y + 60);
    265.     g.drawString("Profits: " + formatNumber(PROFIT_MADE) + " (" + formatNumber(getHourly(PROFIT_MADE, runtime.getRuntime())) + ")", x, y + 75);
    266. }
    267.  
    268. @Overridepublic void onPause() {
    269.     runtime.stop();
    270. }
    271.  
    272. @Overridepublic void onResume() {
    273.     runtime.start();
    274. }
    275.  
    276. }
     
  5. I know I'm not a dev or script bot writer, but it appears to me that it's pressing both because both options are visible any time the interface is open...
    Here's something to try if u think it might work... I don't see why it wouldn't... Just added a check to see if the player is not busy and an extra static delay...
    Code (Text):
    1. /**
    2.      * Teleport to Edgeville.
    3.      */
    4.     private boolean teleportToEdgeville() {
    5.         SlotAction action = ActionBar.getFirstAction(GLORY);
    6.  
    7.         if (action != null) {
    8.             status = "Activating glory.";
    9.             if (action.activate()) {
    10.                 if (teleportToEdgevilleOptionIsVisible() && !isBusy()){
    11.                         // A little extra delay.
    12.                         status = "Selecting Edgeville teleport.";
    13.                         debug("Typing key 49");
    14.                         Keyboard.releaseKey(KeyEvent.VK_2);
    15.                         Execution.delay(1000,2000);
    16.                         Execution.delayUntil(() -> !teleportToEdgevilleOptionIsVisible(), 2000, 4000);
    17.                         return true;
    18.                     }
    19.                 } else {
    20.                     Execution.delayUntil(() -> teleportToEdgevilleOptionIsVisible(), 1000, 1500);
    21.                 }
    22.             }
    23.         }
    24.  
    25.         return false;
    26.     }
    27.  
    28.     /**
    29.      * Teleport to Karamja.
    30.      */
    31.     private boolean teleportToKaramja() {
    32.         SlotAction action = ActionBar.getFirstAction(GLORY);
    33.  
    34.         if (action != null) {
    35.             status = "Activating glory.";
    36.             if (action.activate()) {
    37.                 if (teleportToKaramjaOptionIsVisible() && !isBusy()){
    38.                         // A little extra delay.
    39.                         status = "Selecting Karamja teleport.";
    40.                         debug("Typing key 50");
    41.                         Keyboard.releaseKey(KeyEvent.VK_2);
    42.                         Execution.delay(1000,2000);
    43.                         Execution.delayUntil(() -> !teleportToKaramjaOptionIsVisible(), 2000, 4000);
    44.                         return true;
    45.                     }
    46.                 } else {
    47.                     Execution.delayUntil(() -> teleportToKaramjaOptionIsVisible(), 1000, 1500);
    48.                 }
    49.             }
    50.         }
    51.  
    52.         return false;
    53.     }
    54.  
     
  6. I don't think that's the case - the code contains logic with the effect that the Karamja and Edgeville teleports can only be activated if the player is in a certain area each time.
     
  7. Yes, but he is checking for the option to tele to each place to be on screen and both are on screen at the same time, every time... Both the "teleportToKaramjaOptionIsVisible" and "teleportToEdgeville" check for the same thing...
     
  8. You may be overlooking his atEdgeville() and atKaramja() checks.

    @Arbiter
    @ciresiuol is having trouble replying to this thread, but can reply fine to any others.

    @Geashaw
    Are you sure it's not trying to reactivate the Glory again, hence it typing 1? Try chucking it on a non-bound slot or something and seeing if the problem persists and then we can work from there
     
    #9 SlashnHax, Feb 1, 2015
    Last edited: Feb 1, 2015
    Eagles13 likes this.

Share This Page

Loading...