lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Dec 15, 2011, at 9:53 PM, Patrick Rapin wrote:

Various way to store flags and various way to check them

>    - single concatenated string: "frontonly, backvideo"

if singleConcatenatedString:find( 'frontonly', 1, true ) then
end

>    - a list of strings:  { "frontonly","backvideo" }

for anIndex, aValue in ipairs( aListOfStrings ) do
  if aValue == 'frontonly' then
  end
end

>    - a table with string keys: { frontonly=true, backvideo=true }

if aTableWithStringKeys[ 'backvideo' ] then
end

>    - variable number of parameters: "frontonly", "backvideo"

for anIndex = 1, select( '#', ... ) do
  if select( anIndex, ... ) ==  'frontonly' do
  end
end

The third option, aTableWithStringKeys, looks the most convenient :)