Also, do y’all call main() in the if block or do you just put the code you want to run in the if block?

  • Die Martin Die
    link
    fedilink
    14
    edit-2
    4 days ago
    if debug.getinfo(1).what == "main" then
      -- ...
    end
    

    Not that you’ll ever use it. No, seriously.

    Edit: actually, they are not quite equivalent. This code just checks whether we are outside any function, not necessarily in the main file (i.e. not in a module). I don’t think there’s an equivalent to Python’s __name__ in stock Lua.