From 01c49cadf15bec8b267709da302cef11fd98f7b7 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Fri, 24 Jul 2020 18:20:26 +0200 Subject: [PATCH] state command added --- logic/cart_detector.lua | 7 +++++++ logic/node_detector.lua | 15 +++++++++++++++ logic/player_detector.lua | 8 ++++++++ 3 files changed, 30 insertions(+) diff --git a/logic/cart_detector.lua b/logic/cart_detector.lua index e4cc429..3c672e8 100644 --- a/logic/cart_detector.lua +++ b/logic/cart_detector.lua @@ -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 diff --git a/logic/node_detector.lua b/logic/node_detector.lua index 34cea52..6025598 100644 --- a/logic/node_detector.lua +++ b/logic/node_detector.lua @@ -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, diff --git a/logic/player_detector.lua b/logic/player_detector.lua index ef4a120..8013044 100644 --- a/logic/player_detector.lua +++ b/logic/player_detector.lua @@ -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