From ab9e7040d5a81a87e1ad8f3c1c6ce9f62fc6a027 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Mon, 23 Jan 2023 17:07:45 +0100 Subject: [PATCH] Add state command --- logic/button.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/logic/button.lua b/logic/button.lua index 0d9b82f..f1f2e8c 100644 --- a/logic/button.lua +++ b/logic/button.lua @@ -3,7 +3,7 @@ TechAge ======= - Copyright (C) 2017-2020 Joachim Stolberg + Copyright (C) 2017-2023 Joachim Stolberg AGPL v3 See LICENSE.txt for more information @@ -394,11 +394,16 @@ minetest.register_craft({ }, }) +techage.register_node({"techage:ta3_button_off", "techage:ta3_button_on"}, {}) + techage.register_node({ "techage:ta4_button_off", "techage:ta4_button_on", }, { on_recv_message = function(pos, src, topic, payload) - if topic == "name" then + if topic == "state" then + local name = techage.get_node_lvm(pos).name + return name == "techage:ta4_button_on" and "on" or "off" + elseif topic == "name" then local mem = techage.get_mem(pos) return mem.clicker or "" elseif topic == "time" then @@ -409,7 +414,10 @@ techage.register_node({ end end, on_beduino_request_data = function(pos, src, topic, payload) - if topic == 144 then -- Player Name + if topic == 131 then -- State + local name = techage.get_node_lvm(pos).name + return 0, name == "techage:ta4_button_on" and {1} or {0} + elseif topic == 144 then -- Player Name local mem = techage.get_mem(pos) return 0, mem.clicker elseif topic == 149 then --time