state command added

This commit is contained in:
Joachim Stolberg 2020-07-24 18:20:26 +02:00
parent 2b6fcb5b9b
commit 01c49cadf1
3 changed files with 30 additions and 0 deletions

View File

@ -136,6 +136,13 @@ techage.register_node({"techage:ta3_cartdetector_off", "techage:ta3_cartdetector
local node = minetest.get_node(pos)
local dir = minetest.facedir_to_dir(node.param2)
minecart.punch_cart(pos, nil, 1.5, dir)
elseif topic == "state" then
local node = techage.get_node_lvm(pos)
if node.name == "techage:ta3_cartdetector_on" then
return "on"
else
return "off"
end
else
return "unsupported"
end

View File

@ -187,6 +187,21 @@ minetest.register_craft({
})
techage.register_node({"techage:ta3_nodedetector_off", "techage:ta3_nodedetector_on"}, {
on_recv_message = function(pos, src, topic, payload)
if topic == "name" then
local nvm = techage.get_nvm(pos)
return nvm.player_name or ""
elseif topic == "state" then
local node = techage.get_node_lvm(pos)
if node.name == "techage:ta3_nodedetector_off" then
return "on"
else
return "off"
end
else
return "unsupported"
end
end,
on_node_load = function(pos)
minetest.get_node_timer(pos):start(CYCLE_TIME)
end,

View File

@ -311,6 +311,14 @@ techage.register_node({
if topic == "name" then
local nvm = techage.get_nvm(pos)
return nvm.player_name or ""
elseif topic == "state" then
local node = techage.get_node_lvm(pos)
if node.name == "techage:ta3_playerdetector_on" or
node.name == "techage:ta4_playerdetector_on" then
return "on"
else
return "off"
end
else
return "unsupported"
end