“main” function in Lua?

前端 未结 8 841
醉酒成梦
醉酒成梦 2020-12-01 12:17

In python, one would usually define a main function, in order to allow the script to be used as module (if needed):

def main():
    print(\"Hello world\")
           


        
8条回答
  •  时光取名叫无心
    2020-12-01 12:55

    Maybe you can just deal with the debug library, with the debug.getinfo() function

    if debug.getinfo(1).what == "main" then
        -- Main execution
    end
    

    See the reference manual for more information.

提交回复
热议问题