如何在需要字符串时使用 table?

How to use a table when a string is expected?

我正在尝试 运行 以下脚本来删除项目。 当我尝试 运行 时,它按原样为我提供了以下错误“7:'find' 的参数 #1 错误(预期的结果,得到 table)

我对此很陌生,很难弄清楚如何让它读取 table。

当我输入 UseContainerItemByName("Lost Sole") 时,它可以正常工作,但是我希望它删除 table.

中出现的所有内容

谢谢

    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)

item:find(search) 要求 search 是字符串模式。但是你将 table (itemsToDelete) 传递给了 UseContainerItemByName,因此传递给了 search.

而不是UseContainerItemByName(itemsToDelete),使用

for _, item in ipairs (itemsToDelete) do
    UseContainerItemByName (item)
end