“main” function in Lua?
There’s no “proper” way to do this, since Lua doesn’t really distinguish code by where it came from, they are all just functions. That said, this at least seems to work in Lua 5.1: matthew@silver:~$ cat hybrid.lua if pcall(getfenv, 4) then print(“Library”) else print(“Main file”) end matthew@silver:~$ lua hybrid.lua Main file matthew@silver:~$ lua -lhybrid Library … Read more