Add 2x-button, 2x- and 4x-signal-lamp

This commit is contained in:
Joachim Stolberg 2021-11-06 20:09:11 +01:00
parent c63ef4d557
commit 6e04374f89
33 changed files with 842 additions and 35 deletions

View File

@ -54,8 +54,8 @@ techage.Items = {
ta2_forceload = "techage:forceload",
ta2_driveaxle = "techage:axle",
ta2_generator = "techage:ta2_generator_off",
ta2_winch = "techage:ta2_winch",
ta2_weight_chest = "techage:ta2_weight_chest",
ta2_winch = "techage:ta2_winch",
ta2_weight_chest = "techage:ta2_weight_chest",
---------------------
techage_ta3 = "techage_ta3.png",
techage_ta31 = "techage_ta3b.png",
@ -191,11 +191,12 @@ techage.Items = {
ta4_electricmeter = "techage:ta4_electricmeter",
ta4_transformer = "techage:ta4_transformer",
power_reduction = "techage_power_reduction.png",
ta4_button_2x = "techage:ta4_button_2x",
ta4_button_4x = "techage:ta4_button_4x",
ta4_sequencer = "techage:ta4_sequencer",
ta4_movecontroller = "techage:ta4_movecontroller",
--ta4_ "",
ta4_signallamp_2x = "techage:ta4_signallamp_2x",
ta4_signallamp_4x = "techage:ta4_signallamp_4x",
}
function techage.add_manual_items(table_with_items)

View File

@ -183,7 +183,10 @@ techage.manual_DE.aTitel = {
"3,TA4 Lua Controller Terminal",
"2,TA4 Logik-/Schalt-Module",
"3,TA4 Taster/Schalter / Button/Switch",
"3,TA4 2x Taster / 2x Button",
"3,TA4 4x Taster / 4x Button",
"3,TA4 2x Signallampe / 2x Signal Lamp",
"3,TA4 4x Signallampe / 4x Signal Lamp",
"3,TA4 Spieler Detektor / Player Detector",
"3,TA4 Zustandssammler / State Collector",
"3,TA4 Detektor / Detector",
@ -1562,10 +1565,48 @@ techage.manual_DE.aText = {
"\n"..
"\n"..
"\n",
"Dieser Block hat zwei Taster\\, die über das Schraubenschlüssel-Menü individuell konfiguriert werden können. Für beide Taster kann die Beschriftung und die Zielblockadresse konfiguriert werden. Zusätzlich kann für beide Taster das Kommando konfiguriert werden\\, welches gesendet werden soll.\n"..
"\n"..
"\n"..
"\n",
"Dieser Block hat vier Taster\\, die über das Schraubenschlüssel-Menü individuell konfiguriert werden können. Für jeden Taster kann die Beschriftung und die Zielblockadresse konfiguriert werden. Zusätzlich kann für jeden Taster das Kommando konfiguriert werden\\, welches gesendet werden soll.\n"..
"\n"..
"\n"..
"\n",
"Dieser Block hat zwei Lampen\\, die individuell angesteuert werden können. Jede Lampe kann die Farben \"rot\"\\, \"grün\" und \"orange\" anzeigen. Über das Schraubenschlüssel-Menü kann für beide Lampen die Beschriftung konfiguriert werden. Die Lampen können über folgende Kommandos angesteuert werden:\n"..
"\n"..
"Lampe 1 auf rot schalten: '$send_cmnd(1234\\, \"red\"\\, 1)'\n"..
"\n"..
"Lampe 2 auf grün schalten: '$send_cmnd(1234\\, \"green\"\\, 2)'\n"..
"\n"..
"Lampe 1 auf orange schalten: '$send_cmnd(1234\\, \"amber\"\\, 1)'\n"..
"\n"..
"Lampe 2 aus schalten: '$send_cmnd(1234\\, \"off\"\\, 2)'\n"..
"\n"..
" - \n"..
" - \n"..
" - \n"..
" - \n"..
"\n"..
"\n"..
"\n",
"Dieser Block hat vier Lampen\\, die individuell angesteuert werden können. Jede Lampe kann die Farben \"rot\"\\, \"grün\" und \"orange\" anzeigen. Über das Schraubenschlüssel-Menü kann für alle Lampen die Beschriftung konfiguriert werden. Die Lampen können über folgende Kommandos angesteuert werden:\n"..
"\n"..
"Lampe 1 auf rot schalten: '$send_cmnd(1234\\, \"red\"\\, 1)'\n"..
"\n"..
"Lampe 2 auf grün schalten: '$send_cmnd(1234\\, \"green\"\\, 2)'\n"..
"\n"..
"Lampe 3 auf orange schalten: '$send_cmnd(1234\\, \"amber\"\\, 3)'\n"..
"\n"..
"Lampe 4 aus schalten: '$send_cmnd(1234\\, \"off\"\\, 4)'\n"..
"\n"..
" - \n"..
" - \n"..
" - \n"..
" - \n"..
"\n"..
"\n"..
"\n",
"Beim TA4 Spieler Detektor hat sich nur das Aussehen geändert. Die Funktionalität ist gleich wie beim TA3 Spieler Detektor.\n"..
"\n"..
"\n"..
@ -1984,7 +2025,10 @@ techage.manual_DE.aItemName = {
"ta4_terminal",
"",
"ta4_button",
"ta4_button_2x",
"ta4_button_4x",
"ta4_signallamp_2x",
"ta4_signallamp_4x",
"ta4_playerdetector",
"ta4_collector",
"ta4_detector",
@ -2212,6 +2256,9 @@ techage.manual_DE.aPlanTable = {
"",
"",
"",
"",
"",
"",
"ta4_liquid_filter_base",
"ta4_liquid_filter_gravel",
"ta4_liquid_filter_top",

View File

@ -183,7 +183,10 @@ techage.manual_EN.aTitel = {
"3,TA4 Lua Controller Terminal",
"2,TA4 Logic/Switching Modules",
"3,TA4 Button/Switch",
"3,TA4 2x Button",
"3,TA4 4x Button",
"3,TA4 2x Signal Lamp",
"3,TA4 4x Signal Lamp",
"3,TA4 Player Detector",
"3,TA4 State Collector",
"3,TA4 Detector",
@ -1560,10 +1563,48 @@ techage.manual_EN.aText = {
"\n"..
"\n"..
"\n",
"This block has two buttons that can be individually configured using the wrench menu. The labeling and the target block address can be configured for each button. In addition\\, the command that is to be sent can be configured for each button. \n"..
"\n"..
"\n"..
"\n",
"This block has four buttons that can be individually configured using the wrench menu. The labeling and the target block address can be configured for each button. In addition\\, the command that is to be sent can be configured for each button. \n"..
"\n"..
"\n"..
"\n",
"This block has two lamps that can be controlled individually. Each lamp can display the colors \"red\"\\, \"green\" and \"amber\". The labeling for both lamps can be configured via the wrench menu. The lamps can be controlled using the following commands:\n"..
"\n"..
"Switch lamp 1 to red: '$send_cmnd(1234\\, \"red\"\\, 1)'\n"..
"\n"..
"Switch lamp 2 to green: '$send_cmnd(1234\\, \"green \"\\, 2)'\n"..
"\n"..
"Switch lamp 1 to orange: '$send_cmnd(1234\\, \"amber\"\\, 1)'\n"..
"\n"..
"Switch lamp 2 off: '$send_cmnd(1234\\, \"off\"\\, 2)'\n"..
"\n"..
" - \n"..
" - \n"..
" - \n"..
" - \n"..
"\n"..
"\n"..
"\n",
"This block has four lamps that can be controlled individually. Each lamp can display the colors \"red\"\\, \"green\" and \"amber\". The labeling for all lamps can be configured via the wrench menu. The lamps can be controlled using the following commands:\n"..
"\n"..
"Switch lamp 1 to red: '$send_cmnd(1234\\, \"red\"\\, 1)'\n"..
"\n"..
"Switch lamp 2 to green: '$send_cmnd(1234\\, \"green \"\\, 2)'\n"..
"\n"..
"Switch lamp 3 to orange: '$send_cmnd(1234\\, \"amber\"\\, 3)'\n"..
"\n"..
"Switch lamp 4 off: '$send_cmnd(1234\\, \"off\"\\, 4)'\n"..
"\n"..
" - \n"..
" - \n"..
" - \n"..
" - \n"..
"\n"..
"\n"..
"\n",
"Only the appearance of the TA4 player detector has changed. The functionality is the same as with the TA3 player detector.\n"..
"\n"..
"\n"..
@ -1983,7 +2024,10 @@ techage.manual_EN.aItemName = {
"ta4_terminal",
"",
"ta4_button",
"ta4_button_2x",
"ta4_button_4x",
"ta4_signallamp_2x",
"ta4_signallamp_4x",
"ta4_playerdetector",
"ta4_collector",
"ta4_detector",
@ -2211,6 +2255,9 @@ techage.manual_EN.aPlanTable = {
"",
"",
"",
"",
"",
"",
"ta4_liquid_filter_base",
"ta4_liquid_filter_gravel",
"ta4_liquid_filter_top",

View File

@ -280,7 +280,10 @@ dofile(MP.."/logic/doorblock.lua")
dofile(MP.."/logic/doorcontroller.lua") -- old
dofile(MP.."/logic/doorcontroller2.lua") -- new
dofile(MP.."/logic/collector.lua")
dofile(MP.."/logic/button_2x.lua")
dofile(MP.."/logic/button_4x.lua")
dofile(MP.."/logic/signallamp_2x.lua")
dofile(MP.."/logic/signallamp_4x.lua")
dofile(MP.."/logic/movecontroller.lua")
if minetest.global_exists("mesecon") then
dofile(MP.."/logic/mesecons_converter.lua")

View File

@ -110,12 +110,13 @@ TA3 Booster=TA3 Gebläse
### button.lua ###
Access:=Zugriff:
Command to be sent=Zu sendender Befehl
TA3 Button/Switch=TA3 Taster/Schalter
TA4 Button/Switch=TA4 Schalter/Taster
### button.lua ###
### button_2x.lua ###
### button_4x.lua ###
### signallamp_4x.lua ###
Command=Kommando
@ -141,27 +142,32 @@ Insert destination node number(s)=Gebe Zielnummer(n) ein
Save=Speichern
### button.lua ###
### signallamp_4x.lua ###
### button_2x.lua ###
Command to be sent=Zu sendender Befehl
TA4 2x Button=TA4 2x Taster
### button_2x.lua ###
### button_4x.lua ###
Command to be sent (ignored for switches)=Zu sendender Befehl (wird für Schalter ignoriert)
Label=Beschriftung
Label for the button=Beschriftung für die Taste
Momentary button or on/off switch=Taster oder Ein-/Ausschalter
TA4 4x Button=TA4 4x Taster
Type=Typ
### button_4x.lua ###
### signallamp_4x.lua ###
Access=Zugriff
Button protection=Tastenschutz
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
Number=Nummer
Type=Typ
### button_2x.lua ###
### button_4x.lua ###
### signallamp_2x.lua ###
### signallamp_4x.lua ###
Label=Beschriftung
### button_4x.lua ###
TA4 4x Button=TA4 4x Taster
### cart_detector.lua ###
@ -549,6 +555,21 @@ Hydrogen Cylinder Large=Wasserstoffflasche groß
Hydrogen Cylinder Small=Wasserstoffflasche klein
TA4 Hydrogen=TA4 Wasserstoff
### hyperloop.lua ###
Connected to=Verbunden mit
Connection name for this block=Verbindungsname für diesen Block
Connection name of the remote block=Verbindungsname des entfernten Blocks
Connection status=Verbindungsstatus
Own name=Eigener Name
Provide 'own name' or select a 'remote name' (not both)=Geben Sie nur einmal einen Namen (nicht beides angeben)
Remote name=Name entfernter Block
### hyperloop.lua ###
### sensorchest.lua ###
not connected=nicht verbunden
### industriallamp1.lua ###
TA Industrial Lamp 1=TA Industrielampe 1
@ -961,7 +982,6 @@ TA4 Wind Turbine Nacelle=TA4 Windkraftanlagengondel
Allow public chest access=Erlaube öffentlichen Zugriff
TA4 Sensor Chest=Sensorkiste
not connected=nicht verbunden
### sequencer.lua ###
@ -1004,9 +1024,18 @@ TA4 Wind Turbine Signal Lamp=TA4 Windkraftanlagenlampe
TechAge Signal Lamp=TechAge Signallampe
TechAge Signal Lamp (can be colored)=TechAge Signallampe (kann gefärbt werden)
### signallamp_2x.lua ###
TA4 2x Signal Lamp=TA4 2x Signallampe
### signallamp_2x.lua ###
### signallamp_4x.lua ###
TA4 4x Signal Lamp=
Label for the lamp=Bezeichner der Lampe
### signallamp_4x.lua ###
TA4 4x Signal Lamp=TA4 4x Signallampe
### silicon.lua ###

View File

@ -110,12 +110,13 @@ TA3 Booster=
### button.lua ###
Access:=
Command to be sent=
TA3 Button/Switch=
TA4 Button/Switch=
### button.lua ###
### button_2x.lua ###
### button_4x.lua ###
### signallamp_4x.lua ###
Command=
@ -141,27 +142,32 @@ Insert destination node number(s)=
Save=
### button.lua ###
### signallamp_4x.lua ###
### button_2x.lua ###
Command to be sent=
TA4 2x Button=
### button_2x.lua ###
### button_4x.lua ###
Command to be sent (ignored for switches)=
Label=
Label for the button=
Momentary button or on/off switch=
TA4 4x Button=
Type=
### button_4x.lua ###
### signallamp_4x.lua ###
Access=
Button protection=
Command to be sent (ignored for switches)=
Destination block number=
Label for the button=
Momentary button or on/off switch=
Number=
Type=
### button_2x.lua ###
### button_4x.lua ###
### signallamp_2x.lua ###
### signallamp_4x.lua ###
Label=
### button_4x.lua ###
TA4 4x Button=
### cart_detector.lua ###
@ -549,6 +555,21 @@ Hydrogen Cylinder Large=
Hydrogen Cylinder Small=
TA4 Hydrogen=
### hyperloop.lua ###
Connected to=
Connection name for this block=
Connection name of the remote block=
Connection status=
Own name=
Provide 'own name' or select a 'remote name' (not both)=
Remote name=
### hyperloop.lua ###
### sensorchest.lua ###
not connected=
### industriallamp1.lua ###
TA Industrial Lamp 1=
@ -961,7 +982,6 @@ TA4 Wind Turbine Nacelle=
Allow public chest access=
TA4 Sensor Chest=
not connected=
### sequencer.lua ###
@ -1004,6 +1024,15 @@ TA4 Wind Turbine Signal Lamp=
TechAge Signal Lamp=
TechAge Signal Lamp (can be colored)=
### signallamp_2x.lua ###
TA4 2x Signal Lamp=
### signallamp_2x.lua ###
### signallamp_4x.lua ###
Label for the lamp=
### signallamp_4x.lua ###
TA4 4x Signal Lamp=

243
logic/button_2x.lua Normal file
View File

@ -0,0 +1,243 @@
--[[
TechAge
=======
Copyright (C) 2017-2021 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA4 Logic twofold button
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
local function get_button_num(pos, clicker, pointed_thing)
-- use the node behind the button to get better results
if clicker and pointed_thing then
local offs = vector.subtract(pointed_thing.under, pointed_thing.above)
pointed_thing.under = vector.add(pointed_thing.under, offs)
pointed_thing.above = vector.add(pointed_thing.above, offs)
local pos1 = minetest.pointed_thing_to_face_pos(clicker, pointed_thing)
local y = pos1.y - pos.y
if y > 0.03 then
return 1
elseif y < -0.03 then
return 2
end
end
end
local WRENCH_MENU = {
{
type = "dropdown",
choices = "button,switch",
name = "type",
label = S("Type"),
tooltip = S("Momentary button or on/off switch"),
default = "1",
},
{
type = "ascii",
name = "label1",
label = S("Label") .. " 1",
tooltip = S("Label for the button"),
default = "1",
},
{
type = "numbers",
name = "dest_number1",
label = S("Number") .. " 1",
tooltip = S("Destination block number"),
default = "",
},
{
type = "ascii",
name = "command1",
label = S("Command") .. " 1",
tooltip = S("Command to be sent (ignored for switches)"),
default = "1",
},
{
type = "ascii",
name = "label2",
label = S("Label") .. " 2",
tooltip = S("Label for the button"),
default = "1",
},
{
type = "numbers",
name = "dest_number2",
label = S("Number") .. " 2",
tooltip = S("Destination block number"),
default = "",
},
{
type = "ascii",
name = "command2",
label = S("Command") .. " 2",
tooltip = S("Command to be sent (ignored for switches)"),
default = "2",
},
{
type = "dropdown",
choices = "private,protected,public",
name = "access",
label = S("Access"),
tooltip = S("Button protection"),
default = "8",
},
}
local function send_cmnd(pos, num, cmd)
local meta = M(pos)
local own_num = meta:get_string("node_number")
local dest = meta:get_string("dest_number" .. num)
local command, payload = cmd, nil
if not cmd then
local s = meta:get_string("command" .. num)
command, payload = unpack(string.split(s, " ", false, 1))
end
local owner = meta:get_string("owner")
if techage.check_numbers(dest, owner) then
techage.send_multi(own_num, dest, command, payload)
end
end
local function button_update(pos, objref)
local meta = M(pos)
pos = vector.round(pos)
local nvm = techage.get_nvm(pos)
nvm.button = nvm.button or {}
local tbl = {" ", " ", meta:get_string("label1"), " ", meta:get_string("label2")}
local text = "< " .. table.concat(tbl, "\n< ")
local texture = lcdlib.make_multiline_texture("default", text, 96, 96, 7, "top", "#000", 6)
if nvm.button[1] then
texture = texture .. "^techage_smartline_button_4x_on2.png"
end
if nvm.button[2] then
texture = texture .. "^techage_smartline_button_4x_on3.png"
end
objref:set_properties({ textures = {texture}, visual_size = {x=1, y=1} })
end
local function switch_off(pos, num)
local nvm = techage.get_nvm(pos)
nvm.button = nvm.button or {}
nvm.button[num] = nil
lcdlib.update_entities(pos)
end
local function switch_on(pos, num)
local nvm = techage.get_nvm(pos)
nvm.button = nvm.button or {}
nvm.button[num] = true
lcdlib.update_entities(pos)
end
local lcd_box = {-8/16, -4/16, 7.75/16, 8/16, 4/16, 8/16}
minetest.register_node("techage:ta4_button_2x", {
description = S("TA4 2x Button"),
inventory_image = 'techage_smartline_button_2x.png',
tiles = {'techage_smartline_button_2x.png'},
drawtype = "nodebox",
paramtype = "light",
use_texture_alpha = "clip",
sunlight_propagates = true,
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = lcd_box,
},
light_source = 6,
display_entities = {
["techage:display_entity"] = { depth = 0.48,
on_display_update = button_update},
},
after_place_node = function(pos, placer)
local number = techage.add_node(pos, "techage:ta4_button_2x")
local meta = minetest.get_meta(pos)
meta:set_string("node_number", number)
meta:set_string("owner", placer:get_player_name())
meta:set_string("infotext", "TA4 2x Button " .. number)
meta:set_string("type", "button")
meta:set_string("label1", "B1")
meta:set_string("label2", "B2")
lcdlib.update_entities(pos)
end,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
if clicker and clicker:is_player() then
local playername = clicker:get_player_name()
if minetest.is_protected(pos, playername) then
return
end
-- Check node settings in addition
local access = M(pos):get_string("access")
local owner = M(pos):get_string("owner")
if access == "private" and playername ~= owner then
return
end
local num = get_button_num(pos, clicker, pointed_thing)
if num then
local typ = M(pos):get_string("type")
if typ == "switch" then
local nvm = techage.get_nvm(pos)
nvm.button = nvm.button or {}
if nvm.button[num] then
switch_off(pos, num)
send_cmnd(pos, num, "off")
else
switch_on(pos, num)
send_cmnd(pos, num, "on")
end
else
switch_on(pos, num)
send_cmnd(pos, num)
minetest.after(0.5, switch_off, pos, num)
end
minetest.sound_play("techage_button", {
pos = pos,
gain = 0.5,
max_hear_distance = 5,
})
end
end
end,
ta_after_formspec = function(pos, fields, playername)
lcdlib.update_entities(pos)
end,
after_dig_node = function(pos, oldnode, oldmetadata)
techage.remove_node(pos, oldnode, oldmetadata)
end,
ta3_formspec = WRENCH_MENU,
on_place = lcdlib.on_place,
on_construct = lcdlib.on_construct,
on_destruct = lcdlib.on_destruct,
on_rotate = lcdlib.on_rotate,
groups = {cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_glass_defaults(),
})
minetest.register_craft({
output = "techage:ta4_button_2x",
recipe = {
{"", "", ""},
{"", "techage:ta4_button_off", "techage:ta4_button_off"},
{"", "", ""},
},
})

151
logic/signallamp_2x.lua Normal file
View File

@ -0,0 +1,151 @@
--[[
TechAge
=======
Copyright (C) 2017-2021 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA4 Logic twofold signal lamp
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
local OFF = 0
local RED = 1
local GREEN = 2
local AMBER = 3
local WRENCH_MENU = {
{
type = "ascii",
name = "label1",
label = S("Label") .. " 1",
tooltip = S("Label for the lamp"),
default = "1",
},
{
type = "ascii",
name = "label2",
label = S("Label") .. " 2",
tooltip = S("Label for the lamp"),
default = "2",
},
}
local function lamp_update(pos, objref)
local meta = M(pos)
pos = vector.round(pos)
local nvm = techage.get_nvm(pos)
nvm.lamp = nvm.lamp or {}
local tbl = {" ", " ", meta:get_string("label1"), " ", meta:get_string("label2")}
local text = "< " .. table.concat(tbl, "\n< ")
local texture = lcdlib.make_multiline_texture("default", text, 96, 96, 7, "top", "#000", 6)
if nvm.lamp[1] == RED then
texture = texture .. "^techage_smartline_signal_red2.png"
elseif nvm.lamp[1] == GREEN then
texture = texture .. "^techage_smartline_signal_green2.png"
elseif nvm.lamp[1] == AMBER then
texture = texture .. "^techage_smartline_signal_amber2.png"
end
if nvm.lamp[2] == RED then
texture = texture .. "^techage_smartline_signal_red3.png"
elseif nvm.lamp[2] == GREEN then
texture = texture .. "^techage_smartline_signal_green3.png"
elseif nvm.lamp[2] == AMBER then
texture = texture .. "^techage_smartline_signal_amber3.png"
end
objref:set_properties({ textures = {texture}, visual_size = {x=1, y=1} })
end
local lcd_box = {-8/16, -4/16, 7.75/16, 8/16, 4/16, 8/16}
minetest.register_node("techage:ta4_signallamp_2x", {
description = S("TA4 2x Signal Lamp"),
inventory_image = 'techage_smartline_signal_2x.png^techage_smartline_signal_green2.png^techage_smartline_signal_amber3.png',
tiles = {'techage_smartline_signal_2x.png'},
drawtype = "nodebox",
paramtype = "light",
use_texture_alpha = "clip",
sunlight_propagates = true,
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = lcd_box,
},
light_source = 6,
display_entities = {
["techage:display_entity"] = { depth = 0.48,
on_display_update = lamp_update},
},
after_place_node = function(pos, placer)
local number = techage.add_node(pos, "techage:ta4_signallamp_2x")
local meta = minetest.get_meta(pos)
meta:set_string("node_number", number)
meta:set_string("owner", placer:get_player_name())
meta:set_string("infotext", S("TA4 2x Signal Lamp") .. " " .. number)
local nvm = techage.get_nvm(pos)
nvm.lamp = {}
lcdlib.update_entities(pos)
end,
after_dig_node = function(pos, oldnode, oldmetadata)
techage.remove_node(pos, oldnode, oldmetadata)
end,
ta_after_formspec = function(pos, fields, playername)
lcdlib.update_entities(pos)
end,
ta3_formspec = WRENCH_MENU,
on_place = lcdlib.on_place,
on_construct = lcdlib.on_construct,
on_destruct = lcdlib.on_destruct,
on_rotate = lcdlib.on_rotate,
groups = {cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_glass_defaults(),
})
techage.register_node({"techage:ta4_signallamp_2x"}, {
on_recv_message = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
nvm.lamp = nvm.lamp or {}
if topic == "green" then
local num = math.min(tonumber(payload) or 0, 2)
nvm.lamp[num] = GREEN
lcdlib.update_entities(pos)
elseif topic == "amber" then
local num = math.min(tonumber(payload) or 0, 2)
nvm.lamp[num] = AMBER
lcdlib.update_entities(pos)
elseif topic == "red" then
local num = math.min(tonumber(payload) or 0, 2)
nvm.lamp[num] = RED
lcdlib.update_entities(pos)
elseif topic == "off" then
local num = math.min(tonumber(payload) or 0, 2)
nvm.lamp[num] = OFF
lcdlib.update_entities(pos)
end
end,
})
minetest.register_craft({
output = "techage:ta4_signallamp_2x",
recipe = {
{"", "techage:aluminum", "dye:blue"},
{"", "default:glass", "techage:ta4_wlanchip"},
{"", "techage:ta4_leds", "techage:ta4_leds"},
},
})

182
logic/signallamp_4x.lua Normal file
View File

@ -0,0 +1,182 @@
--[[
TechAge
=======
Copyright (C) 2017-2021 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA4 Logic fourfold signal lamp
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
local OFF = 0
local RED = 1
local GREEN = 2
local AMBER = 3
local WRENCH_MENU = {
{
type = "ascii",
name = "label1",
label = S("Label") .. " 1",
tooltip = S("Label for the lamp"),
default = "1",
},
{
type = "ascii",
name = "label2",
label = S("Label") .. " 2",
tooltip = S("Label for the lamp"),
default = "2",
},
{
type = "ascii",
name = "label3",
label = S("Label") .. " 3",
tooltip = S("Label for the lamp"),
default = "3",
},
{
type = "ascii",
name = "label4",
label = S("Label") .. " 4",
tooltip = S("Label for the lamp"),
default = "4",
},
}
local function lamp_update(pos, objref)
local meta = M(pos)
pos = vector.round(pos)
local nvm = techage.get_nvm(pos)
nvm.lamp = nvm.lamp or {}
local tbl = {meta:get_string("label1"), " ", meta:get_string("label2"), " ", meta:get_string("label3"), " ", meta:get_string("label4")}
local text = "< " .. table.concat(tbl, "\n< ")
local texture = lcdlib.make_multiline_texture("default", text, 96, 96, 7, "top", "#000", 6)
if nvm.lamp[1] == RED then
texture = texture .. "^techage_smartline_signal_red1.png"
elseif nvm.lamp[1] == GREEN then
texture = texture .. "^techage_smartline_signal_green1.png"
elseif nvm.lamp[1] == AMBER then
texture = texture .. "^techage_smartline_signal_amber1.png"
end
if nvm.lamp[2] == RED then
texture = texture .. "^techage_smartline_signal_red2.png"
elseif nvm.lamp[2] == GREEN then
texture = texture .. "^techage_smartline_signal_green2.png"
elseif nvm.lamp[2] == AMBER then
texture = texture .. "^techage_smartline_signal_amber2.png"
end
if nvm.lamp[3] == RED then
texture = texture .. "^techage_smartline_signal_red3.png"
elseif nvm.lamp[3] == GREEN then
texture = texture .. "^techage_smartline_signal_green3.png"
elseif nvm.lamp[3] == AMBER then
texture = texture .. "^techage_smartline_signal_amber3.png"
end
if nvm.lamp[4] == RED then
texture = texture .. "^techage_smartline_signal_red4.png"
elseif nvm.lamp[4] == GREEN then
texture = texture .. "^techage_smartline_signal_green4.png"
elseif nvm.lamp[4] == AMBER then
texture = texture .. "^techage_smartline_signal_amber4.png"
end
objref:set_properties({ textures = {texture}, visual_size = {x=1, y=1} })
end
local lcd_box = {-8/16, -8/16, 7.75/16, 8/16, 8/16, 8/16}
minetest.register_node("techage:ta4_signallamp_4x", {
description = S("TA4 4x Signal Lamp"),
inventory_image = 'techage_smartline_signal_4x.png^techage_smartline_signal_off1.png^techage_smartline_signal_green2.png^techage_smartline_signal_amber3.png^techage_smartline_signal_red4.png',
tiles = {'techage_smartline_signal_4x.png'},
drawtype = "nodebox",
paramtype = "light",
use_texture_alpha = "clip",
sunlight_propagates = true,
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = lcd_box,
},
light_source = 6,
display_entities = {
["techage:display_entity"] = { depth = 0.48,
on_display_update = lamp_update},
},
after_place_node = function(pos, placer)
local number = techage.add_node(pos, "techage:ta4_signallamp_4x")
local meta = minetest.get_meta(pos)
meta:set_string("node_number", number)
meta:set_string("owner", placer:get_player_name())
meta:set_string("infotext", S("TA4 4x Signal Lamp") .. " " .. number)
local nvm = techage.get_nvm(pos)
nvm.text = {"1", "", "2", "", "3", "", "4"}
nvm.lamp = {}
lcdlib.update_entities(pos)
end,
after_dig_node = function(pos, oldnode, oldmetadata)
techage.remove_node(pos, oldnode, oldmetadata)
end,
ta_after_formspec = function(pos, fields, playername)
lcdlib.update_entities(pos)
end,
ta3_formspec = WRENCH_MENU,
on_place = lcdlib.on_place,
on_construct = lcdlib.on_construct,
on_destruct = lcdlib.on_destruct,
on_rotate = lcdlib.on_rotate,
groups = {cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_glass_defaults(),
})
techage.register_node({"techage:ta4_signallamp_4x"}, {
on_recv_message = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
nvm.lamp = nvm.lamp or {}
if topic == "green" then
local num = math.min(tonumber(payload) or 0, 4)
nvm.lamp[num] = GREEN
lcdlib.update_entities(pos)
elseif topic == "amber" then
local num = math.min(tonumber(payload) or 0, 4)
nvm.lamp[num] = AMBER
lcdlib.update_entities(pos)
elseif topic == "red" then
local num = math.min(tonumber(payload) or 0, 4)
nvm.lamp[num] = RED
lcdlib.update_entities(pos)
elseif topic == "off" then
local num = math.min(tonumber(payload) or 0, 4)
nvm.lamp[num] = OFF
lcdlib.update_entities(pos)
end
end,
})
minetest.register_craft({
output = "techage:ta4_signallamp_4x",
recipe = {
{"", "techage:ta4_signallamp_2x", ""},
{"", "techage:ta4_signallamp_2x", ""},
{"", "", ""},
},
})

View File

@ -470,12 +470,46 @@ Beim TA4 Taster/Schalter hat sich nur das Aussehen geändert. Die Funktionalitä
[ta4_button|image]
### TA4 2x Taster / 2x Button
Dieser Block hat zwei Taster, die über das Schraubenschlüssel-Menü individuell konfiguriert werden können. Für beide Taster kann die Beschriftung und die Zielblockadresse konfiguriert werden. Zusätzlich kann für beide Taster das Kommando konfiguriert werden, welches gesendet werden soll.
[ta4_button_2x|image]
### TA4 4x Taster / 4x Button
Dieser Block hat vier Taster, die über das Schraubenschlüssel-Menü individuell konfiguriert werden können. Für jeden Taster kann die Beschriftung und die Zielblockadresse konfiguriert werden. Zusätzlich kann für jeden Taster das Kommando konfiguriert werden, welches gesendet werden soll.
[ta4_button_4x|image]
### TA4 2x Signallampe / 2x Signal Lamp
Dieser Block hat zwei Lampen, die individuell angesteuert werden können. Jede Lampe kann die Farben "rot", "grün" und "orange" anzeigen. Über das Schraubenschlüssel-Menü kann für beide Lampen die Beschriftung konfiguriert werden. Die Lampen können über folgende Kommandos angesteuert werden:
- Lampe 1 auf rot schalten: `$send_cmnd(1234, "red", 1)`
- Lampe 2 auf grün schalten: `$send_cmnd(1234, "green", 2)`
- Lampe 1 auf orange schalten: `$send_cmnd(1234, "amber", 1)`
- Lampe 2 aus schalten: `$send_cmnd(1234, "off", 2)`
[ta4_signallamp_2x|image]
### TA4 4x Signallampe / 4x Signal Lamp
Dieser Block hat vier Lampen, die individuell angesteuert werden können. Jede Lampe kann die Farben "rot", "grün" und "orange" anzeigen. Über das Schraubenschlüssel-Menü kann für alle Lampen die Beschriftung konfiguriert werden. Die Lampen können über folgende Kommandos angesteuert werden:
- Lampe 1 auf rot schalten: `$send_cmnd(1234, "red", 1)`
- Lampe 2 auf grün schalten: `$send_cmnd(1234, "green", 2)`
- Lampe 3 auf orange schalten: `$send_cmnd(1234, "amber", 3)`
- Lampe 4 aus schalten: `$send_cmnd(1234, "off", 4)`
[ta4_signallamp_4x|image]
### TA4 Spieler Detektor / Player Detector
Beim TA4 Spieler Detektor hat sich nur das Aussehen geändert. Die Funktionalität ist gleich wie beim TA3 Spieler Detektor.

View File

@ -463,12 +463,47 @@ Only the appearance of the TA4 button/switch has changed. The functionality is t
[ta4_button|image]
### TA4 2x Button
This block has two buttons that can be individually configured using the wrench menu. The labeling and the target block address can be configured for each button. In addition, the command that is to be sent can be configured for each button.
[ta4_button_2x|image]
### TA4 4x Button
This block has four buttons that can be individually configured using the wrench menu. The labeling and the target block address can be configured for each button. In addition, the command that is to be sent can be configured for each button.
[ta4_button_4x|image]
### TA4 2x Signal Lamp
This block has two lamps that can be controlled individually. Each lamp can display the colors "red", "green" and "amber". The labeling for both lamps can be configured via the wrench menu. The lamps can be controlled using the following commands:
- Switch lamp 1 to red: `$send_cmnd(1234, "red", 1)`
- Switch lamp 2 to green: `$send_cmnd(1234, "green ", 2)`
- Switch lamp 1 to orange: `$send_cmnd(1234, "amber", 1)`
- Switch lamp 2 off: `$send_cmnd(1234, "off", 2)`
[ta4_signallamp_2x|image]
### TA4 4x Signal Lamp
This block has four lamps that can be controlled individually. Each lamp can display the colors "red", "green" and "amber". The labeling for all lamps can be configured via the wrench menu. The lamps can be controlled using the following commands:
- Switch lamp 1 to red: `$send_cmnd(1234, "red", 1)`
- Switch lamp 2 to green: `$send_cmnd(1234, "green ", 2)`
- Switch lamp 3 to orange: `$send_cmnd(1234, "amber", 3)`
- Switch lamp 4 off: `$send_cmnd(1234, "off", 4)`
[ta4_signallamp_4x|image]
### TA4 Player Detector
Only the appearance of the TA4 player detector has changed. The functionality is the same as with the TA3 player detector.

View File

@ -182,7 +182,10 @@
- [TA4 Lua Controller Terminal](./manual_ta4_DE.md#ta4-lua-controller-terminal)
- [TA4 Logik-/Schalt-Module](./manual_ta4_DE.md#ta4-logik-schalt-module)
- [TA4 Taster/Schalter / Button/Switch](./manual_ta4_DE.md#ta4-tasterschalter--buttonswitch)
- [TA4 2x Taster / 2x Button](./manual_ta4_DE.md#ta4-2x-taster--2x-button)
- [TA4 4x Taster / 4x Button](./manual_ta4_DE.md#ta4-4x-taster--4x-button)
- [TA4 2x Signallampe / 2x Signal Lamp](./manual_ta4_DE.md#ta4-2x-signallampe--2x-signal-lamp)
- [TA4 4x Signallampe / 4x Signal Lamp](./manual_ta4_DE.md#ta4-4x-signallampe--4x-signal-lamp)
- [TA4 Spieler Detektor / Player Detector](./manual_ta4_DE.md#ta4-spieler-detektor--player-detector)
- [TA4 Zustandssammler / State Collector](./manual_ta4_DE.md#ta4-zustandssammler--state-collector)
- [TA4 Detektor / Detector](./manual_ta4_DE.md#ta4-detektor--detector)

View File

@ -182,7 +182,10 @@
- [TA4 Lua Controller Terminal](./manual_ta4_EN.md#ta4-lua-controller-terminal)
- [TA4 Logic/Switching Modules](./manual_ta4_EN.md#ta4-logicswitching-modules)
- [TA4 Button/Switch](./manual_ta4_EN.md#ta4-buttonswitch)
- [TA4 2x Button](./manual_ta4_EN.md#ta4-2x-button)
- [TA4 4x Button](./manual_ta4_EN.md#ta4-4x-button)
- [TA4 2x Signal Lamp](./manual_ta4_EN.md#ta4-2x-signal-lamp)
- [TA4 4x Signal Lamp](./manual_ta4_EN.md#ta4-4x-signal-lamp)
- [TA4 Player Detector](./manual_ta4_EN.md#ta4-player-detector)
- [TA4 State Collector](./manual_ta4_EN.md#ta4-state-collector)
- [TA4 Detector](./manual_ta4_EN.md#ta4-detector)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 642 B

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B