|
|
||
|
Hi, I know in python it is possible to detect if a file is used as a module or used as the main programm. And if it is run as the main programm run a main function. Is it possible to do the same with lua ? I tried with some debug functions without success.
I've been using this (suppose the file is called "test.lua"):
if arg[0]:find("test%.lua$") then
main()
end
It's not foolproof. The end user could have renamed the file "test.lua".
Or he could be running some other program that ends in "test.lua".
// Niklas