diff --git a/locale/techage.de.tr b/locale/techage.de.tr index 7255c5b..9def28a 100644 --- a/locale/techage.de.tr +++ b/locale/techage.de.tr @@ -128,9 +128,15 @@ TA4 Button/Switch=TA4 Schalter/Taster Access=Zugriff Button protection=Tastenschutz +Type=Typ + +### button.lua ### +### button_2x.lua ### +### button_4x.lua ### +### player_detector.lua ### + Command=Kommando Number=Nummer -Type=Typ ### button.lua ### ### cart_detector.lua ### @@ -163,10 +169,15 @@ TA4 2x Button=TA4 2x Taster ### button_4x.lua ### Command to be sent (ignored for switches)=Zu sendender Befehl (wird für Schalter ignoriert) -Destination block number=Zielblocknummer Label for the button=Beschriftung für die Taste Momentary button or on/off switch=Taster oder Ein-/Ausschalter +### button_2x.lua ### +### button_4x.lua ### +### player_detector.lua ### + +Destination block number=Zielblocknummer + ### button_2x.lua ### ### button_4x.lua ### ### signallamp_2x.lua ### @@ -961,6 +972,8 @@ Plastic Granules=Plastikgranulat ### player_detector.lua ### +Command to send when player is detected=Befehl zum Senden, wenn ein Spieler erkannt wird +Command to send when player moves away=Befehl zum Senden, wenn sich der Spieler wegbewegt Radius=Radius Search radius=Suchradius TA4 Player Detector=TA4 Spieler Detektor diff --git a/locale/template.txt b/locale/template.txt index 55fb86a..91e06c9 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -128,9 +128,15 @@ TA4 Button/Switch= Access= Button protection= +Type= + +### button.lua ### +### button_2x.lua ### +### button_4x.lua ### +### player_detector.lua ### + Command= Number= -Type= ### button.lua ### ### cart_detector.lua ### @@ -163,10 +169,15 @@ TA4 2x Button= ### button_4x.lua ### Command to be sent (ignored for switches)= -Destination block number= Label for the button= Momentary button or on/off switch= +### button_2x.lua ### +### button_4x.lua ### +### player_detector.lua ### + +Destination block number= + ### button_2x.lua ### ### button_4x.lua ### ### signallamp_2x.lua ### @@ -961,6 +972,8 @@ Plastic Granules= ### player_detector.lua ### +Command to send when player is detected= +Command to send when player moves away= Radius= Search radius= TA4 Player Detector= diff --git a/logic/button.lua b/logic/button.lua index 7efc19d..0d9b82f 100644 --- a/logic/button.lua +++ b/logic/button.lua @@ -68,10 +68,7 @@ local function switch_on(pos) elseif name == "techage:ta4_button_off" then logic.swap_node(pos, "techage:ta4_button_on") end - local meta = M(pos) - local s = meta:contains("command") and meta:get_string("command") or "on" - local command, payload = unpack(string.split(s, " ", false, 1)) - logic.send_cmnd(pos, M(pos), command, payload, cycle_time) + logic.send_cmnd(pos, "command", "on", cycle_time) minetest.sound_play("techage_button", { pos = pos, gain = 0.5, diff --git a/logic/lib.lua b/logic/lib.lua index 248c3ff..83165f8 100644 --- a/logic/lib.lua +++ b/logic/lib.lua @@ -67,13 +67,16 @@ function techage.logic.send_on(pos, meta, time) return own_num == numbers end -function techage.logic.send_cmnd(pos, meta, cmnd, payload, time) +function techage.logic.send_cmnd(pos, ident, default, time) + local meta = M(pos) + local s = meta:contains(ident) and meta:get_string(ident) or default + local command, payload = unpack(string.split(s, " ", false, 1)) local own_num = meta:get_string("node_number") or "" local numbers = meta:get_string("numbers") or "" if time and time > 0 then minetest.get_node_timer(pos):start(time) end - techage.send_multi(own_num, numbers, cmnd, payload) + techage.send_multi(own_num, numbers, command, payload) end function techage.logic.send_off(pos, meta) diff --git a/logic/player_detector.lua b/logic/player_detector.lua index 51afc0b..e234b06 100644 --- a/logic/player_detector.lua +++ b/logic/player_detector.lua @@ -29,17 +29,39 @@ local WRENCH_MENU = { tooltip = S("Search radius"), default = "4", }, + { + type = "numbers", + name = "numbers", + label = S("Number"), + tooltip = S("Destination block number"), + default = "", + check = techage.check_numbers, + }, + { + type = "ascii", + name = "command1", + label = "On " .. S("Command"), + tooltip = S("Command to send when player is detected"), + default = "on", + }, + { + type = "ascii", + name = "command2", + label = "Off " .. S("Command"), + tooltip = S("Command to send when player moves away"), + default = "off", + }, } local function switch_on(pos, stage) if logic.swap_node(pos, "techage:ta"..stage.."_playerdetector_on") then - logic.send_on(pos, M(pos)) + logic.send_cmnd(pos, "command1", "on") end end local function switch_off(pos, stage) if logic.swap_node(pos, "techage:ta"..stage.."_playerdetector_off") then - logic.send_off(pos, M(pos)) + logic.send_cmnd(pos, "command2", "off") end end