Basic Lua syntax
Lua has a simple syntax that is easy to both learn and 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... -- 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" } --[[ When the Lua script is called from FreeSWITCH you have a few magic objects. The main one is the 'freeswitch' object: freeswitch.consoleLog("INFO","This is a log line\n") If script is executed from dialplan (eg: there is an incoming call to manage) you have the 'session' object which lets you manipulate the call:...