Am I doing something wrong? (Potential bug?)

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

  1. 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. 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. 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. New issue: It drops about 5 and then stops the script bot...
     
  5. Can you post the stack trace (if there is an error thrown in the console) ?
     
  6. dropAll is only one SpriteItem. Please post the stacktrace and/or your new code
     
  7. Very strange how it would only drop 5.. mind posting your new code?
     
  8. I'm almost positive that's it's an issue with your code if it's only dropping 5.
     
  9. 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. Did you post your updated code?
     
  11. Issue Resolved forgot to add the execution delay, lock thread :)
     
  12. 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.
  13. 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.     }
     

Share This Page

Loading...