Import only needed once project

, ,

All files imported from main.lua (and imported from files imported from main.lua, and so on) are compiled into a single pdz file, and import runs the code from the file only once. A second import call from anywhere in the pdz will do nothing.

I've only now read this. I've been religiously adding import statements to the top of each file.

What if I have the same function in different files though? How do I make unambiguous references?

I'm not entirely sure what you mean here. By "same function" do you mean the different files all have their own version of a function with the same name as the others'? The imported file has its own context, so if the functions are declared local the imported code wouldn't be able to see those. If they're global, then they'll overwrite each other as each file is run.

I'm probably misunderstanding the whole thing, though.. Can you give a minimal example showing this?