All scripts are written to the MapScript.lua file, or split into separate files as needed and connected using doFile(). All code written "without a wrapper" is executed when the map starts; everything inside functions is executed only when the function is called.
Thank you, I figured it out, it works ;)
Added after 17 hours 22 minutes
How does doFile work?