Created
July 28, 2016 20:19
-
-
Save Luca0208/47e4629572e2bf2cdf8545bd8bc056ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Please remember this is out of context | |
--at the beginning of your program | |
local ids = {1,2,3,4} | |
local function isAllowed(id) | |
for i = 1,#ids do | |
if id == ids[i] then return true end | |
end | |
return false | |
end | |
--when you want to check for id and message | |
if isAllowed(id) and message == "blah" then | |
--code | |
end | |
--If you have multiple messages, but the same ids do this: | |
if isAllowed(id) then | |
if message == "blah" then | |
--code for blah | |
elseif message == "something" then | |
--code for something | |
end | |
end | |
--this way you are not iterating over the table multiple times |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment