Username: Password:

Author Topic: [Share] Drop unwanted items with a queue.  (Read 1571 times)

Offline =Mindee=

  • Commander Shepard
  • BOT Developer Administrator
  • Dragon
  • *****
  • Posts: 2,788
  • Cookies 9020
  • We'll bang, OKAY?
    • View Profile
    • http://mindee-bot.com
[Share] Drop unwanted items with a queue.
« on: April 18, 2020, 10:42:03 AM »
If bot can't drop item (no room, etc), it adds item to the queue and drops it later when possible.

Tested, working, but of course it needs more tests.  [badpokerface]

(For version 2.0.13++)

Script:
Code: [Select]
# Drop items by id:
drop_items_by_id_list = (6405, 2584)

queue = {}

# Private function
def checkDropQueue(x, y, z):
if script.IsLocationFree(x, y, z) == 1:
if len(queue) > 0: # there are items in queue, try to drop them
for slot, itemId in queue.items():
if script.GetItemInSlot(slot) == itemId:
if script.DropItem(slot, 0) == 'ok':
script.StatusMessage('Dropping item from queue.')
queue.pop(slot) # Deletes item from queue
break
else:
script.StatusMessage('Deleted item from queue.')
queue.pop(slot) # Deletes item from queue, because it's not in slot.


def onScriptActivation():
script.PZChecksForDrop(0) # allow to drop items in protection zone

def onChangeLocation(x, y, z):
checkDropQueue(x, y, z)

def onReceiveAddItemToBackpack(slot, itemId):
if itemId in drop_items_by_id_list:
if script.DropItem(slot, 1) == 'no_room':
script.StatusMessage('No room! Adding to queue.')
queue[slot] = itemId # add item to queue and drop it later






Mindee-BOT creator, founder and developer.