ICTA controller: Add exchange command

This commit is contained in:
Joachim Stolberg 2021-03-07 11:06:11 +01:00
parent 4410af0064
commit 5d3b4213ab
2 changed files with 37 additions and 3 deletions

View File

@ -179,7 +179,7 @@ techage.icta_register_condition("state", {
type = "textlist", type = "textlist",
name = "value", name = "value",
label = "", label = "",
choices = "stopped,running,standby,blocked,nopower,fault,unloaded,invalid,on,off", choices = "stopped,running,standby,blocked,nopower,fault,unloaded,invalid,on,off,empty,loaded,loading,full",
default = "stopped", default = "stopped",
}, },
{ {
@ -793,3 +793,36 @@ techage.icta_register_condition("get_filter", {
return condition, result return condition, result
end, end,
}) })
techage.icta_register_action("exchange", {
title = "place/remove a block via the Door Controller II",
formspec = {
{
type = "number",
name = "number",
label = "number",
default = "",
},
{
type = "number",
name = "slot",
label = "slot no",
default = "1",
},
{
type = "label",
name = "lbl",
label = "place/remove a block via\nthe Door Controller II\n",
},
},
button = function(data, environ)
return 'exch('..techage.fmt_number(data.number)..","..data.slot..')'
end,
code = function(data, environ)
return function(env, output, idx)
local payload = data.slot
techage.send_single(environ.number, data.number, "exchange", payload)
end
end,
})

View File

@ -351,7 +351,7 @@ techage.register_node({"techage:ta3_logic2"}, {
nvm.blocking_time = nvm.blocking_time or M(pos):get_float("blocking_time") nvm.blocking_time = nvm.blocking_time or M(pos):get_float("blocking_time")
nvm.inp_tbl = nvm.inp_tbl or {} nvm.inp_tbl = nvm.inp_tbl or {}
if src ~= nvm.own_num and techage.SystemTime > (mem.ttl or 0) then if src ~= nvm.own_num then
if topic == "on" then if topic == "on" then
nvm.inp_tbl[src] = "on" nvm.inp_tbl[src] = "on"
elseif topic == "off" then elseif topic == "off" then
@ -360,8 +360,9 @@ techage.register_node({"techage:ta3_logic2"}, {
return "unsupported" return "unsupported"
end end
local t = math.max((mem.ttl or 0) - techage.SystemTime, 0.1)
minetest.get_node_timer(pos):start(t)
mem.ttl = techage.SystemTime + (nvm.blocking_time or 0) mem.ttl = techage.SystemTime + (nvm.blocking_time or 0)
minetest.get_node_timer(pos):start(0.1)
end end
end, end,
}) })