Reputation: 123
I am trying to run a simple program, but for some reason an error comes out.
I have version 5.3.5 with https://sourceforge.net/projects/luabinaries/files/. Installed on Windows version 10.0.16299.1087. The launch was made from lua53.exe
command main.lua
.
enter image description here
print('Hello, World!')
Error Traceback:
stdin:1: attempt to index a nil value (global 'main')
stack traceback:
stdin:1: in main chunk
[C]: in ?
Upvotes: 1
Views: 424
Reputation: 1403
To run a .lua file from the command line, run
lua53 myfile.lua
Simply invoking
lua53
will launch a Lua REPL (ie, you can write statements that are evaluated not in the context of any file).
However, from the REPL you can use the dofile
function to execute the contents of a file:
dofile("myfile.lua")
What you were trying to do, just writing main.lua
inside the REPL, was attempting to use the filename as though it were a Lua script. Since main
was not previously defined, you got that error.
Upvotes: 1