How import .lua files?

Hello everybody!
I’m a newbie in Corona/Solar2D.
And I faced with problem - how inport .lua files in my project?
I am a programmer with practice and am used to breaking code into small pieces.
I saw that in Lua it is possible to import files, but an error appears in Corona.

no such file or directory

Hello!
To import a file, you need to add it to the project folder and connect via require.

Examples:

  1. added the server.lua file to the project folder (next to the main.lua file). Now, to access it from the Main.lua file, I write
    local server = require (“server”)

  2. added the file to the src folder (src / server.lua). Connect like this:
    local server = require (“src.server”)

Documentation: link require

3 Likes