如何在期望字符串的位置使用表格?

我尝试运行以下脚本以删除项目。 当我尝试按原样运行时,它会向我提供以下错误"7 :Bad argument #1 to 'find' (stirng expected,got table)

我非常新手,很难想出如何使它可以读取表格。

当我放入UseContainerItemByName("Lost Sole")时,它可以正常工作,但我希望它能删除所有在表格中出现的内容。

谢谢

    local DeleteCursor = function (...) return __LB__.Unlock(DeleteCursorItem, ...) end

function UseContainerItemByName(search)
   for bag = 0,4 do
      for slot = 1,GetContainerNumSlots(bag) do
         local item = GetContainerItemLink(bag,slot)
         if item and item:find(search) then
            PickupContainerItem(bag,slot)
            DeleteCursor(bag,slot)
         end
      end
   end
end

itemsToDelete = {
    "Lost Sole",
    "Oribobber",
    "Elysian Thade Bait",
    "Old Glove",
    "Rusty Chain",
    "Broken Fishing Pole",
    "Elysian Thade Bait",
    "Lost Sole Bait",
    "Partially Eaten Fish",
    "Shrouded Cloth Bandage"
}

UseContainerItemByName(itemsToDelete)
点赞
用户6632736
用户6632736

item:find(search) 要求 search 是一个字符串模式。但是您将一个表(itemsToDelete)传递给了 UseContainerItemByName,因此也传递到了 search

使用 UseContainerItemByName(itemsToDelete) 代替,使用

for _, item in ipairs (itemsToDelete) do
    UseContainerItemByName (item)
end
2021-02-16 07:19:21