lua-users home
lua-l archive

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

2013/4/15 Chris Datfung <>:

> Thanks. In this case, I'm stuck with Lua 5.1, is there anything comparable
> to goto in 5.1?

No. You could make a function of the whole thing and say 'return "Blue"'
instead of 'Decision="Blue"'. But here's a neater solution.

function chosen(x) return tonumber(ChooseSetting(x)) end

Decision = (chosen(a) and chosen(b) and chosen(c) and "Blue")
        or (chosen(d) and chosen(e) and "Red")
        or (chosen(f) and "Yellow") or "Orange

The logical functions do shortcut evalation, so it will skip unnecessary