Fix item caching bugs

This commit is contained in:
2020-09-20 23:41:55 -06:00
parent f8d44e7e38
commit 6489984640
5 changed files with 75 additions and 19 deletions
+15 -8
View File
@@ -15,6 +15,8 @@ import blocks
importlib.reload(blocks)
import items
importlib.reload(items)
import data
importlib.reload(data)
class LumberjackStates:
@@ -377,9 +379,10 @@ class CacheItemsStates:
return None
def init(self):
#if len(self.g.inv) >= 27:
if len(self.g.inv) >= 2:
self.state = self.find_chest_spot
num_stacks = len(self.g.inv)
print('inventory amount:', num_stacks)
if num_stacks >= 27:
self.state = self.find_cache_spot
else:
print('Aborting caching, not full')
self.state = self.cleanup
@@ -453,8 +456,8 @@ class CacheItemsStates:
if self.g.item_lock: return
w = self.g.window
w_data = data.WINDOWS[w.window_type]
w_inventory_slots = w_data.inventory
w_info = data.WINDOWS[w.data.window_type]
w_inventory_slots = w_info.inventory
for slot_num in w_inventory_slots:
if slot_num not in w.contents:
@@ -462,24 +465,28 @@ class CacheItemsStates:
slot = w.contents[slot_num]
if not slot.present:
continue
if slot.item_id in items.USEFUL_ITEMS:
continue
print('moving', slot)
inv_slot_num = slot_num - w_data.slot_diff
inv_slot_num = slot_num - w_info.slot_diff
self.g.inv.pop(inv_slot_num, None)
self.g.item_lock = True
self.g.game.click_window(w.window_id, slot_num, 0, 1, slot)
self.g.game.click_window(slot_num, 0, 1, slot)
return
print('nothing left to move')
self.state = close_chest
self.state = self.close_chest
def close_chest(self):
print('closing chest')
self.g.game.close_window()
self.g.chat.send('cache at ' + str(self.area)[1:-1])
self.state = self.cleanup
def cleanup(self):