From 1a57bbf4025b8cdcb3a2fa99085d13168198ff7f Mon Sep 17 00:00:00 2001 From: Kyle Coburn Date: Mon, 13 Apr 2015 00:49:25 -0700 Subject: [PATCH] Improve support for naming both swap items --- ai/strategies.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ai/strategies.lua b/ai/strategies.lua index 5c9c32f..805e58d 100644 --- a/ai/strategies.lua +++ b/ai/strategies.lua @@ -675,10 +675,18 @@ Strategies.functions = { end local itemIndex = Inventory.indexOf(data.item) local destIndex = data.dest + local hasSwappedItems if type(destIndex) == "string" then destIndex = Inventory.indexOf(destIndex) + if destIndex < 0 then + p("Not available to swap", data.item, data.dest) + return true + end + hasSwappedItems = itemIndex < destIndex + else + hasSwappedItems = itemIndex == destIndex end - if itemIndex == destIndex then + if hasSwappedItems then if Strategies.closeMenuFor(data) then return true end