Programming in Lua - 1.4
Programming in Lua - 1.4
Programming in Lua
Part I. The Language
Chapter 1. Getting Started
#!/usr/local/bin/lua
#!/usr/bin/env lua
Everything is optional.
As we have seen already, when we call lua without
arguments
the interpreter enters in interactive mode.
lua>
which assigns the string " lua> " to the global variable _PROMPT.
A main script can retrieve its arguments in the global variable arg.
In a call
like
arg[-3] = "lua"
arg[-2] = "-e"
arg[-1] = "sin=math.sin"
arg[0] = "script"
arg[1] = "a"
arg[2] = "b"
More often than not, the script only uses the positive indices
(arg[1] and
arg[2], in the example).