Quick Lua If question

I'm trying to set up a nested alias, where I can hit the root with one part, then use a pair of arguments to change a set of variables. So far my block looks like this:

if matches[2]=="A" then
 if matches[3]=="a" then
  A="a"
 elseif matches[3]=="b"then
  A="b"
 else
  echo("Generic Error Message Here")
elseif matches[2]=="B" then
 if matches[3]=="a" then
  B="a"
 elseif ...

My question is: Can I simplify the second part of those blocks to look more like

if matches[2]=="A" then
 if matches[3]==["a"|"b"|"c"] then
  A=matches[3]
 else
  echo("Generic Error Message Here")
...

 or

...
elseif matches[2]=="B" then
 if matches[3]=="a" or matches[3]=="b" or matches[3]=="c" then
  B=matches[3]
 else
  echo("Same Error Message Here")
 ...

or if I need to use full if blocks for the second set.
image

Best Answer

Answers

  • The pattern does limit the choices, but this for a harvest/upkeep trigger set, so the first argument getting passed will define which variable is being changed (the gem type) and the second is meant to tell that variable what fills it (which thing to upkeep for that gem). So basically I want to do har corral cloth and have it set the corral variable to cloth. But if I accidentally, for whatever reason, were to do har copse cloth, then it would instead tell me it can't do that. The second syntax should work well for that, thanks.
    image
Sign In or Register to comment.