Basic Lua syntax
Lua has a simple syntax that is easy both to learn and to read. The following is a simple script:
-- This is a sample Lua script
-- Single line comments begin with two dashes
--[[
This is a multi-line comment.
Everything between the double square brackets
is part of the comment block.
]]
-- Lua is loosely typed
var = 1 -- This is a comment
var ="alpha" -- Another comment
var ="A1" -- You get the idea...
--[[
When the Lua script is called from the dialplan
you have a few magic objects. A handy one is
the 'freeswitch' object which lets you do things
like this:
freeswitch.consoleLog("INFO","This is a log line\n")
Another important one is the 'session' object which
Lets you manipulate the call:
session:answer()
session:hangup()
]]
-- Lua makes extensive use of tables
-- Tables are a hybrid of arrays and associative arrays
val1 = 1
val2 = 2
my_table = {
key1 = val1,
key2 = val2,
"index 1",
"index 2"
}
freeswitch.consoleLog...