Even loadfile() (and dofile(), which I forgot to disable, and will get disabled in tomorrow's release), you'd just execute the file as another chunk (i.e. in a "child" Lua state, with its own locality), so you won't be able to reach functions defined in that loaded file...
To achieve what you want, you may simply split your program into several *.lua files, then specify the said files (in the proper order, so that the main program that will call functions defined in other files, will be specified last) to luac:
You could also use a pre-processor (like "cpp" in C/C++)... AFAIK, there is no official pre-processor for luac, but (under Linux, or with mingw/cygwin under Windows) you could just use cpp itself, using #include "some_included_lua_file.lua"
in your main automation.lua "sources".
Example for automation.lua:
Example for my_lua_functions.lua:
Then, using cpp to assemble your Lua script and pass it to luac:
The "-P" option instructs cpp not
to add its own comments/references in the output file (since luac won't understand them), "-nostdinc" tells it not
to search for C headers outside the current directory (where both your "my_lua_functions.lua" and "automation.lua" should reside: if "my_lua_functions.lua" is elsewhere you can tell cpp with its "-I" option where to look for), and "-pipe" allows to send the resulting pre-processed sources to the standard output, which gets connected to the standard input of luac thanks to the pipe ("|") character and the "-" last option in luac's command line.
Now, check that it worked:
Which should print: Hello world !
As a bonus, you could use most cpp directives (#define, #if/#else/#endif, etc) in your code...