Am I doing something wrong? (Potential bug?)

Discussion in 'Developer Support' started by Divinity, Mar 26, 2014.

  1. Divinity

    Joined:
    Mar 21, 2014
    Messages:
    36
    Likes Received:
    7
    So in my fisher i have this code once the inventory is full, I know it reaches this point as I am debugging every step and the debug logs show it to be in this phase...

    [​IMG]

    It does Drop only ONE fish out of the 26 in inventory...
    Theoretically either i'm just completely stupid or it should work?
     
  2. Viewer

    Viewer Discretion is advised

    Joined:
    Jan 2, 2014
    Messages:
    305
    Likes Received:
    73
    I think thats because you stored the fish you want to drop.. lets say that your dropAll variable gets a fish on slot 20, if you drop it, that item will be null so you cant drop it anymore, inside your while loop, you should loop through all items in your inventory and interact with any item with the "raw" string. Try it :p
     
  3. Booch

    Joined:
    Mar 9, 2014
    Messages:
    40
    Likes Received:
    8
    What viewer is saying is correct. The SpriteItem is being declared and assigned once as a single RandomItem so try putting that underneath your while loop so the dropAll will be assigned every time to another fish through each loop
     
  4. Divinity

    Joined:
    Mar 21, 2014
    Messages:
    36
    Likes Received:
    7
    New issue: It drops about 5 and then stops the script bot...
     
  5. Viewer

    Viewer Discretion is advised

    Joined:
    Jan 2, 2014
    Messages:
    305
    Likes Received:
    73
    Can you post the stack trace (if there is an error thrown in the console) ?
     
  6. dog_

    dog_ 0xCAFEBABE

    Joined:
    Nov 3, 2013
    Messages:
    270
    Likes Received:
    55
    dropAll is only one SpriteItem. Please post the stacktrace and/or your new code
     
  7. Booch

    Joined:
    Mar 9, 2014
    Messages:
    40
    Likes Received:
    8
    Very strange how it would only drop 5.. mind posting your new code?
     
  8. Cloud

    Joined:
    Jul 28, 2013
    Messages:
    2,585
    Likes Received:
    931
    I'm almost positive that's it's an issue with your code if it's only dropping 5.
     
  9. Divinity

    Joined:
    Mar 21, 2014
    Messages:
    36
    Likes Received:
    7
    100% I am just trying to get direction as to where in my code it's happening, i knew it wasnt client related with 2nd bug :p
     
  10. Cloud

    Joined:
    Jul 28, 2013
    Messages:
    2,585
    Likes Received:
    931
    Did you post your updated code?
     
  11. Divinity

    Joined:
    Mar 21, 2014
    Messages:
    36
    Likes Received:
    7
  12. Divinity

    Joined:
    Mar 21, 2014
    Messages:
    36
    Likes Received:
    7
    Issue Resolved forgot to add the execution delay, lock thread :)
     
  13. Salvation

    Salvation First Bot Author

    Joined:
    Aug 7, 2013
    Messages:
    264
    Likes Received:
    67
    dropAll is null, this frequently happens between gameticks, while a new region is loaded or the user is having minor connectivity issues.
    As for the actual programming, containsAnyOf uses getItem and getRandomItem uses getItem: you're calling it twice, while that is not needed!

    Code (Text):
    1.  
    2.     private void dropInventory() {
    3.         SpriteItem item = null;
    4.         //Iterate a maximum of 28 times, in case we are somehow unable to actually drop items at all
    5.         for (int i = 0; i < 28 && (item = Inventory.getRandomItem("Raw trout", "Raw salmon")) != null; i++) {
    6.             if (item.interact("Drop")) {
    7.                 //Sucessfully dropped, might want to sleep a little bit or not
    8.             }
    9.         }
    10.     }
    11.  
     
    Cloud likes this.
  14. Viewer

    Viewer Discretion is advised

    Joined:
    Jan 2, 2014
    Messages:
    305
    Likes Received:
    73
    Try this:
    Code (Text):
    1.    public void drop(String... itemNames) {
    2.         while(Inventory.containsAnyOf(itemNames)) {
    3.             for (final SpriteItem item : Inventory.getItems()) {
    4.                 for (String name : itemNames) {
    5.                     if(item != null && item.getDefinition().getName().toLowerCase().contains(name.toLowerCase())) {
    6.                         if (item.interact("Drop")) {
    7.                             Execution.delay(210,280);
    8.                         }
    9.                     }
    10.                 }
    11.             }
    12.         }
    13.     }
     
  15. Divinity

    Joined:
    Mar 21, 2014
    Messages:
    36
    Likes Received:
    7

Share This Page

Loading...