samedi 23 octobre 2021

How do I make an arbitrary number of if conditions in lua that I could generate from another function?

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

I want to be able to reuse this piece of code. Is it possible to generate a string from a function somewhere and use that string for arbitrary number of if conditions? Let's say I wanna add item.uicategory == 50 and/or item.uicategory == 1 in there. Is it possible in lua? How would I approach this?

Aucun commentaire:

Enregistrer un commentaire