-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWebSocketAlert.lua
More file actions
33 lines (29 loc) · 952 Bytes
/
Copy pathWebSocketAlert.lua
File metadata and controls
33 lines (29 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Instance.properties = properties({
{ name="AlertName", type="Text", value="Alert", onUpdate="onNameUpdate" },
{ name="onAction", type="Alert" },
{ name="Variables", type="PropertyGroup", items={
{ name="TextVariables", type="ObjectSet", set_types={type="PolyPopObject", index="WebSocket.TextVariables"} }
}}
})
function Instance:onInit()
self:onNameUpdate()
end
function Instance:onNameUpdate()
self:setName(self.properties.AlertName)
end
function Instance:onMessage(data)
local args = {}
local textVariableCount = self.properties.Variables.TextVariables:getKit():getObjectCount()
if (textVariableCount > 0) then
for v=1,textVariableCount do
local textVariable = self.properties.Variables.TextVariables:getKit():getObjectByIndex(v)
args[textVariable.properties.VariableName] = textVariable.properties.Default
end
end
if data.text then
for k, v in pairs(data.text) do
args[k] = v
end
end
self.onAction:raise(args)
end