如何在 lua 中创建一个任意数量的 if 条件,以便我可以从另一个函数生成?

if (item.type >= startbag and item.type <= endbag) and not item.isuntradeable and item.equipslot ~= 0 and item.ishq then
    gFatCat.count.goodies = gFatCat.count.goodies + 1
    gFatCat.item.goodies[gFatCat.count.goodies] = item
    ml_debug(string.format("[FatCat] - #% 3d - Count: %3d - Name: %s Bag: %d Slot: %d", gFatCat.count.goodies, item.count, item.name, item.type, item.slot))
end

我想重用这一段代码。是否可能从某个函数生成一个字符串,并将该字符串用于任意数量的 if 条件中?假设我想在其中添加 item.uicategory == 50 和 / 或 item.uicategory == 1。在lua中有可能吗?我该如何着手解决?

原文链接 https://stackoverflow.com/questions/69689133

点赞