using tables to match items
Posted: Tue Feb 25, 2014 12:29 pm
I have a question about when and where you can use a table to match items.
Is it possible to use a table of items in an if statement? For example, let's look at this. Suppose I want to keep only the following potions: 203502,203503,203497,203498,203492,203493. How would I do something like this:
I'm pretty sure that wouldn't work? But not sure? Would I instead have to do something like:?
It just seems like there should be an easier way of doing that. That's how I would normally do it, but I didn't know if there's a much shorter, easier way to do it. Any help would be appreciated. Thanks.
Is it possible to use a table of items in an if statement? For example, let's look at this. Suppose I want to keep only the following potions: 203502,203503,203497,203498,203492,203493. How would I do something like this:
Code: Select all
if item:isType("Potions") and item.Id ~= {203502,203503,203497,203498,203492,203493} then
item:delete()
end
Code: Select all
keepItems = {203502,203503,203497,203498,203492,203493}
if item:isType("Potions") then
local dokeep = 0
for i, mypots in pairs(keepItems) do
if item.Id == mypots then
dokeep = dokeep +1
end
end
if dokeep == 0 then
item:delete()
end
end