12
statement will look like the following (
bold
indicates the output):
>a=10
>if a == 5 then
>> print(“pass”)
>>else
>>print(“fail”)
>>end
fail
Interactive mode also supports a special prefix “=” that will cause the interpreter to print the
value of the expression to the right of the “=” sign. For example (
bold
indicates the output):
>a=10+5
>=a
15
There are a few limitations to interactive mode. Notably, each statement is executed as its own
Lua script; therefore local variables are not carried over to the next statement. The following
example illustrates this (
bold
indicates the output):
>local b=10
>print(b)
nil
>c=10
>print(c)
10
Another notable limitation is the inability to print tables.
There is no command to exit interactive mode. The user may exit interactive mode by simply
disconnecting from the scripting raw socket. When the user re-connects to the scripting raw
socket he/she will return to normal mode. Interactive mode is a great tool to learn and
experiment with the Lua language; however most script development will be done by writing
scripts into files that are uploaded and run.