Files
q-sys-call-queue/caller.qplug
T

84 lines
1.8 KiB
Plaintext

PluginInfo = {
Name = "Caller",
Version = "0.1.0-master",
Id = "Caller.plugin.0.1.0-master",
Description = "Plugin for taking a name and input and producing a call output",
Author = "Joel Wetzell"
}
require("json")
function GetPrettyName()
return "Caller"
end
function GetProperties()
local props = {}
return props
end
function RectifyProperties(props)
return props
end
function GetControls(props)
local controls = {
{
Name = "Clear",
ControlType = "Button",
ButtonType = "Trigger",
PinStyle = "Input",
UserPin = true
},
{
Name = "QueueUp",
ControlType = "Button",
ButtonType = "Toggle",
PinStyle = "Both",
UserPin = true
},
{
Name = "CallOut",
ControlType = "Text",
PinStyle = "Output",
UserPin = true
},
{
Name = "CallerName",
ControlType = "Text",
PinStyle = "Input",
UserPin = true
}
}
return controls
end
function Initialize()
end
function CreateCall(name, queue)
local call = {
Queue = queue,
Name = name,
Time = os.time()
}
return call
end
function SetupControlHandlers()
Controls["QueueUp"].EventHandler = function (ctrl)
local call = CreateCall(Controls["CallerName"].String, Controls["QueueUp"].Boolean)
Controls["CallOut"].String = json.encode(call)
end
Controls["Clear"].EventHandler = function (ctrl)
Controls["QueueUp"].Boolean = false
local call = CreateCall(Controls["CallerName"].String, false)
Controls["CallOut"].String = json.encode(call)
end
end
if(Controls) then
Initialize()
SetupControlHandlers()
end