pakruojinis 11 Posted October 5, 2021 Hello all, recently tried making a script and ran into this error, while trying to pick up more than 1 item from the ground, even with a code like this, it only picks up 1 item and just seems to ignore every other pickup request and continues with the script, it is the same item. for (int i = 0; i < 28; i++) { if (item != null) { item.interact("Take"); }
Pseudo 179 Posted October 5, 2021 - Show us where you're assigning a value to 'item'. - Why are you iterating 28 times? - You should be sleeping (dynamically) upon interaction to avoid 'spam clicking'.
pakruojinis 11 Author Posted October 6, 2021 21 hours ago, Pseudo said: - Show us where you're assigning a value to 'item'. - Why are you iterating 28 times? - You should be sleeping (dynamically) upon interaction to avoid 'spam clicking'. - I get this problem with any item, logs, axes, shields whatever - That's how much an inventory can hold - Yes, I have tried it with sleeps, and will use them if I this solved, just didn't bother putting it here, thank you
Pseudo 179 Posted October 6, 2021 2 hours ago, pakruojinis said: - I get this problem with any item, logs, axes, shields whatever - That's how much an inventory can hold - Yes, I have tried it with sleeps, and will use them if I this solved, just didn't bother putting it here, thank you Yeah as I said before, can you show your declaration of 'item'?
Koschei 147 Posted October 7, 2021 I would assume this would be from calling the same ground item instance to keep attempting to pick up. IE once you pick up the first item, that item is no longer on the ground. So say there are 28 donuts on the ground. Once you pick up the first donut, you need to either do another query to grab the next instance or query the list of them to take from and iterate through each element in the list until you successfully pick up 28 items. Although, you really should have it check if your inventory is full. If not, pick up an item and sleep for a small duration or something.
Hosfad 155 Posted October 7, 2021 On 10/5/2021 at 8:19 PM, pakruojinis said: Hello all, recently tried making a script and ran into this error, while trying to pick up more than 1 item from the ground, even with a code like this, it only picks up 1 item and just seems to ignore every other pickup request and continues with the script, it is the same item. for (int i = 0; i < 28; i++) { if (item != null) { item.interact("Take"); } i would assume your item variable is not resetting after you pick up the first item , since the following works just fine for (GroundItem groundItem : GroundItems.all()){ if (groundItem!=null){ groundItem.interact("Take"); } }
pakruojinis 11 Author Posted October 7, 2021 18 hours ago, Pseudo said: Yeah as I said before, can you show your declaration of 'item'? GroundItem logs = GroundItems.closest("Logs"); if (logs != null) { for (int i = 0; i < 5; i++) { if (logs != null) { logs.interact("Take"); } // changing the logs to anything won't do anything differently 10 hours ago, Koschei said: I would assume this would be from calling the same ground item instance to keep attempting to pick up. IE once you pick up the first item, that item is no longer on the ground. So say there are 28 donuts on the ground. Once you pick up the first donut, you need to either do another query to grab the next instance or query the list of them to take from and iterate through each element in the list until you successfully pick up 28 items. Although, you really should have it check if your inventory is full. If not, pick up an item and sleep for a small duration or something. This was pretty random for me, I tried checking for the inventory, and it seemed to spam click on it, but because of the delay I could not see if it actually picks up all 5 (I lowered the count for testing), after adding some sleeps it now just clicks once for whatever reason 1 hour ago, Hosfad said: i would assume your item variable is not resetting after you pick up the first item , since the following works just fine for (GroundItem groundItem : GroundItems.all()){ if (groundItem!=null){ groundItem.interact("Take"); } } Could you please post this with any item written into it, I tried it and it just seemed to wanna open random doors and spazz out, here's what I tried. I appreaciate you all helping me for (GroundItem Logs : GroundItems.all()){ if (Logs!=null){ Logs.interact("Take"); } }
wr80 15 Posted October 7, 2021 I use the follow code for an area around me: itemsOnGround = GroundItems.all(); for (GroundItem i : itemsOnGround) { if(lootArea.contains(i)){ if (itemsToPickup.contains(i.getName())) { MethodProvider.log("found a match to loot list"); i.interact("Take"); } } } Area is around me, and the itemsToPickup is a list of items. Updated to remove my food dropper 3 weeks later that's fine but sleep until inventory listener so you can know when you pick it up.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.