如何使用一个表时,一个字符串的预期?



我试图运行以下脚本来删除项目。当我尝试按原样运行它时,它为我提供了以下错误"7:错误参数#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)

item:find(search)要求search为字符串模式。然而,您将表(itemsToDelete)传递给UseContainerItemByName,从而传递给search

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

相关内容

  • 没有找到相关文章

最新更新