Add callqueue.qplug

This commit is contained in:
2026-04-23 13:49:17 +00:00
parent ae5c6ae358
commit 3fc8183a97
+129
View File
@@ -0,0 +1,129 @@
PluginInfo = {
Name = "CallQueue",
Version = "0.1.0-master",
Id = "callqueue.plugin.0.1.0-master",
Description = "Plugin for taking incoming call objects and maintaining a queue",
Author = "Joel Wetzell"
}
require("json")
function GetPrettyName()
return "Call Queue"
end
function GetProperties()
local props = {
{
Name = "Call Count",
Type = "integer",
Min = 0,
Max = 20,
Value = 1
},
}
return props
end
function RectifyProperties(props)
return props
end
function GetControls(props)
local controls = {
{
Name = "PopCall",
ControlType = "Button",
ButtonType = "Trigger",
PinStyle = "Input",
UserPin = true
},
{
Name = "TopCallName",
ControlType = "Text",
PinStyle = "Output",
UserPin = true
},
}
for i=1,props["Call Count"].Value do
print(i)
local name = "Call" .. i
table.insert(controls, {
Name = name,
ControlType = "Text",
PinStyle = "Input",
UserPin = true
})
end
return controls
end
function ClearCalls()
CallList = {}
end
function UpdateOutputs()
local topCall = CallList[1]
if topCall == nil then
Controls["TopCallName"].String = ""
else
Controls["TopCallName"].String = topCall.Name
end
end
function PushCall(call)
for i, value in pairs(CallList) do
if value.Position == call.Position then
print("call already in queue for position " .. call.Position)
return
end
end
table.insert(CallList, call)
print("call for " .. call.Name .. " at position " .. call.Position .. " pushed")
UpdateOutputs()
end
function PopCall()
call = table.remove(CallList,1)
if call then
print("call for " .. call.Name .. " at position " .. call.Position .. " popped")
end
UpdateOutputs()
end
function RemoveCall(call)
for i, value in pairs(CallList) do
if value.Position == call.Position then
print("removing call for position " .. call.Position)
table.remove(CallList, i)
return
end
end
end
function Initialize()
ClearCalls()
end
function SetupControlHandlers()
Controls["PopCall"].EventHandler = function (ctrl)
PopCall()
end
for i=1, Properties["Call Count"].Value do
Controls["Call"..i].EventHandler = function (ctrl)
if ctrl.String ~= "" then
local call = json.decode(ctrl.String)
call.Position = i
if call.Queue then
PushCall(call)
else
RemoveCall(call)
end
end
end
end
end
if(Controls) then
Initialize()
SetupControlHandlers()
end