lua-users home
lua-l archive

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


I have a script that needs to test for various conditions and based on the result of the initial test result it tests for others. For example, based on the results of the ChooseSetting(a) function I want to run ChooseSetting(b) or skip down to the next test. Using the code below though if Setting1 equals 5 but Setting2 equals -2 I don't skip down and calculate a value for Setting4 (for example). How can I rewrite the if statement to jump out of the current block if the Setting* value is less than zero and continue with the next test?

Thanks
Chris

===========================================================

    Setting1 = ChooseSetting(a)
    if tonumber(Setting1) > 0 then
      Setting2 = ChooseSetting(b)
      if tonumber(Setting2) > 0 then
        Setting3 = ChooseSetting(c)
        if tonumber(Setting3) > 0 then
          Decision = "Blue"
        end
      end
    else
      Setting4 = ChooseSetting(d)
      if tonumber(Setting4) > 0 then
        Setting5 = ChooseSetting(e)
        if tonumber(Setting5) > 0 then
          Decision = "Red"
        end
      else
        Setting5 = ChooseSetting(f)
        if tonumber(Setting5) > 0 then
          Decision = "Yellow"
        else
          Decision = "Orange"
        end
      end
    end