Small refactor
Signed-off-by: Rahix <rahix@rahix.de>
This commit is contained in:
parent
50ae923ef7
commit
e8ec24dacc
1 changed files with 17 additions and 19 deletions
36
bc.lua
36
bc.lua
|
|
@ -280,25 +280,23 @@ function BaseControl:set(name, value)
|
||||||
local old = self.local_nouns[name]
|
local old = self.local_nouns[name]
|
||||||
self.local_nouns[name] = value
|
self.local_nouns[name] = value
|
||||||
|
|
||||||
if self.listeners[name] ~= nil then
|
for id, l in pairs(self.listeners[name] or {}) do
|
||||||
for id, l in pairs(self.listeners[name]) do
|
if (l.query.ty == Query.Change.ty and value ~= old)
|
||||||
if (l.query.ty == Query.Change.ty and value ~= old)
|
or (l.query.ty == Query.Rising.ty and value > old)
|
||||||
or (l.query.ty == Query.Rising.ty and value > old)
|
or (l.query.ty == Query.Falling.ty and value < old)
|
||||||
or (l.query.ty == Query.Falling.ty and value < old)
|
or (l.query.ty == Query.Equals.ty and value == l.query.v)
|
||||||
or (l.query.ty == Query.Equals.ty and value == l.query.v)
|
or (l.query.ty == Query.Above.ty and value > l.query.v)
|
||||||
or (l.query.ty == Query.Above.ty and value > l.query.v)
|
or (l.query.ty == Query.Below.ty and value < l.query.v)
|
||||||
or (l.query.ty == Query.Below.ty and value < l.query.v)
|
then
|
||||||
then
|
if l.callback ~= nil then
|
||||||
if l.callback ~= nil then
|
l.callback(value)
|
||||||
l.callback(value)
|
else
|
||||||
else
|
self.network:send(l.addr, {
|
||||||
self.network:send(l.addr, {
|
ty=Message.ListenNotify,
|
||||||
ty=Message.ListenNotify,
|
noun=name,
|
||||||
noun=name,
|
id=id,
|
||||||
id=id,
|
value=value,
|
||||||
value=value,
|
})
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue