Add new signal lamp with color commands

This commit is contained in:
Joachim Stolberg 2022-09-10 16:04:45 +02:00
parent 4702f46b07
commit 4f0cacb224
11 changed files with 216 additions and 122 deletions

View File

@ -1126,7 +1126,7 @@ techage.manual_DE.aText = {
"\n".. "\n"..
"\n", "\n",
"Die Signallampe kann mit 'on'/'off' Kommando ein- bzw. ausgeschaltet werden. Diese Lampe braucht keinen Strom und\n".. "Die Signallampe kann mit 'on'/'off' Kommando ein- bzw. ausgeschaltet werden. Diese Lampe braucht keinen Strom und\n"..
"kann mit der Spritzpistole aus der Mod \"Unified Dyes\" farbig gemacht werden.\n".. "kann mit der Spritzpistole aus der Mod \"Unified Dyes\" und über Lua/Beduino Kommandos eingefärbt werden.\n"..
"\n".. "\n"..
"\n".. "\n"..
"\n", "\n",

View File

@ -1128,8 +1128,7 @@ techage.manual_EN.aText = {
"\n".. "\n"..
"\n".. "\n"..
"\n", "\n",
"The signal lamp can be switched on or off with the 'on' / 'off' command. This lamp does not need electricity and\n".. "The signal lamp can be switched on or off with the 'on' / 'off' command. This lamp does not need electricity and can be colored with the airbrush tool from the mod Unified Dyes\" and via Lua/Beduino commands.\n"..
"can be colored with the airbrush tool of the mod Unified Dyes.\n"..
"\n".. "\n"..
"\n".. "\n"..
"\n", "\n",

View File

@ -1042,7 +1042,9 @@ no oil=Kein Öl
### pusher.lua ### ### pusher.lua ###
Optionally configure@nthe pusher with one item=Der Schieber kann optional@nmit einem Gegenstand@nkonfiguriert werden Number of items=Anzahl der Elemente
Number of items that are allowed to be pushed=Anzahl der Elemente, die verschoben werden dürfen
Optionally configure@nthe pusher with one item=Der Schieber kann optional@nmit einem Elemente@nkonfiguriert werden
Pusher=Schieber Pusher=Schieber
### quarry.lua ### ### quarry.lua ###
@ -1166,7 +1168,7 @@ TA5 Fusion Reactor Shell=TA5 Fusionsreaktor Hülle
TA4 Wind Turbine Signal Lamp=TA4 Windkraftanlagenlampe TA4 Wind Turbine Signal Lamp=TA4 Windkraftanlagenlampe
TechAge Signal Lamp=TechAge Signallampe TechAge Signal Lamp=TechAge Signallampe
TechAge Signal Lamp (can be colored)=TechAge Signallampe (kann gefärbt werden) TechAge Signal Lamp 2 =TechAge Signallampe 2
### signallamp_2x.lua ### ### signallamp_2x.lua ###

View File

@ -1042,6 +1042,8 @@ no oil=
### pusher.lua ### ### pusher.lua ###
Number of items=
Number of items that are allowed to be pushed=
Optionally configure@nthe pusher with one item= Optionally configure@nthe pusher with one item=
Pusher= Pusher=
@ -1166,7 +1168,7 @@ TA5 Fusion Reactor Shell=
TA4 Wind Turbine Signal Lamp= TA4 Wind Turbine Signal Lamp=
TechAge Signal Lamp= TechAge Signal Lamp=
TechAge Signal Lamp (can be colored)= TechAge Signal Lamp 2 =
### signallamp_2x.lua ### ### signallamp_2x.lua ###

View File

@ -8,7 +8,7 @@
AGPL v3 AGPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
Colored Signal Lamp (requires unifieddyes) Colored Signal Lamps (with unifieddyes support)
]]-- ]]--
@ -20,32 +20,48 @@ local logic = techage.logic
local COLORED = minetest.get_modpath("unifieddyes") and minetest.global_exists("unifieddyes") local COLORED = minetest.get_modpath("unifieddyes") and minetest.global_exists("unifieddyes")
local LampsOff = {}
local LampsOn = {}
local function switch_on(pos, node) local function switch_on(pos, node, player, color)
node.name = "techage:signal_lamp_on" if player and minetest.is_protected(pos, player:get_player_name()) then
return
end
color = (tonumber(color) or COLORED and 96 or 6) % 256
if LampsOff[node.name] then
node.name = LampsOff[node.name]
node.param2 = color
minetest.swap_node(pos, node)
elseif LampsOn[node.name] and color ~= node.param2 then
node.param2 = color
minetest.swap_node(pos, node) minetest.swap_node(pos, node)
end end
local function switch_off(pos, node)
node.name = "techage:signal_lamp_off"
minetest.swap_node(pos, node)
end end
minetest.register_node("techage:signal_lamp_off", { local function switch_off(pos, node, player)
description = S("TechAge Signal Lamp (can be colored)"), if player and minetest.is_protected(pos, player:get_player_name()) then
tiles = {"techage_signal_lamp.png^[colorize:#000000:100"}, return
drawtype = "nodebox", end
node_box = { if LampsOn[node.name] then
type = "fixed", node.name = LampsOn[node.name]
fixed = { node.param2 = COLORED and 241 or 35
{-6/16, -6/16, -6/16, 6/16, 6/16, 6/16}, minetest.swap_node(pos, node)
{-4/16, -10/16, -4/16, 4/16, -6/16, 4/16}, end
}, end
},
local function register_signallamp(name, description, tiles, node_box)
LampsOff[name .. "_off"] = name .. "_on"
LampsOn[name .. "_on"] = name .. "_off"
minetest.register_node(name .. "_off", {
description = description,
tiles = tiles,
drawtype = node_box and "nodebox",
node_box = node_box,
after_place_node = function(pos, placer, itemstack, pointed_thing) after_place_node = function(pos, placer, itemstack, pointed_thing)
logic.after_place_node(pos, placer, "techage:signal_lamp_off", S("TechAge Signal Lamp")) logic.after_place_node(pos, placer, name .. "_off", description)
logic.infotext(M(pos), S("TechAge Signal Lamp")) logic.infotext(M(pos), description)
if COLORED then if COLORED then
unifieddyes.recolor_on_place(pos, placer, itemstack, pointed_thing) unifieddyes.recolor_on_place(pos, placer, itemstack, pointed_thing)
end end
@ -57,6 +73,10 @@ minetest.register_node("techage:signal_lamp_off", {
techage.remove_node(pos, oldnode, oldmetadata) techage.remove_node(pos, oldnode, oldmetadata)
if COLORED then if COLORED then
unifieddyes.after_dig_node(pos, oldnode, oldmetadata, digger) unifieddyes.after_dig_node(pos, oldnode, oldmetadata, digger)
else
local node = minetest.get_node(pos)
node.param2 = 35
minetest.swap_node(pos, node)
end end
end, end,
@ -65,37 +85,30 @@ minetest.register_node("techage:signal_lamp_off", {
paramtype = "light", paramtype = "light",
paramtype2 = "color", paramtype2 = "color",
palette = COLORED and "unifieddyes_palette_extended.png" or 'techage_color16.png', --palette = "techage_palette256.png",
palette = COLORED and "unifieddyes_palette_extended.png" or "techage_palette256.png",
place_param2 = 241, place_param2 = 241,
sunlight_propagates = true, sunlight_propagates = true,
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_glass_defaults(),
groups = {choppy=2, cracky=1, ud_param2_colorable = 1}, groups = {choppy=2, cracky=1, ud_param2_colorable = 1},
is_ground_content = false, is_ground_content = false,
drop = "techage:signal_lamp_off" drop = name .. "_off"
}) })
minetest.register_node(name .. "_on", {
description = description,
tiles = tiles,
drawtype = node_box and "nodebox",
node_box = node_box,
minetest.register_node("techage:signal_lamp_on", {
description = S("TechAge Signal Lamp"),
tiles = {"techage_signal_lamp.png"},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-6/16, -6/16, -6/16, 6/16, 6/16, 6/16},
{-4/16, -10/16, -4/16, 4/16, -6/16, 4/16},
},
},
on_rightclick = switch_off, on_rightclick = switch_off,
paramtype = "light", paramtype = "light",
paramtype2 = "color", paramtype2 = "color",
palette = COLORED and "unifieddyes_palette_extended.png" or 'techage_color16.png', --palette = "techage_palette256.png",
palette = COLORED and "unifieddyes_palette_extended.png" or "techage_palette256.png",
groups = {choppy=2, cracky=1, not_in_creative_inventory=1, ud_param2_colorable = 1}, groups = {choppy=2, cracky=1, not_in_creative_inventory=1, ud_param2_colorable = 1},
on_construct = COLORED and unifieddyes.on_construct or nil,
after_place_node = COLORED and unifieddyes.recolor_on_place or nil,
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)
techage.remove_node(pos, oldnode, oldmetadata) techage.remove_node(pos, oldnode, oldmetadata)
if COLORED then if COLORED then
@ -106,17 +119,23 @@ minetest.register_node("techage:signal_lamp_on", {
on_dig = COLORED and unifieddyes.on_dig or nil, on_dig = COLORED and unifieddyes.on_dig or nil,
light_source = 10, light_source = 10,
is_ground_content = false, is_ground_content = false,
drop = "techage:signal_lamp_off" drop = name .. "_off"
}) })
techage.register_node({"techage:signal_lamp_off", "techage:signal_lamp_on"}, { techage.register_node({name .. "_off", name .. "_on"}, {
on_recv_message = function(pos, src, topic, payload) on_recv_message = function(pos, src, topic, payload)
if topic == "on" then if topic == "on" then
local node = techage.get_node_lvm(pos) local node = techage.get_node_lvm(pos)
switch_on(pos, node) switch_on(pos, node)
return true
elseif topic == "off" then elseif topic == "off" then
local node = techage.get_node_lvm(pos) local node = techage.get_node_lvm(pos)
switch_off(pos, node) switch_off(pos, node)
return true
elseif topic == "color" then
local node = techage.get_node_lvm(pos)
switch_on(pos, node, nil, payload)
return true
else else
return "unsupported" return "unsupported"
end end
@ -130,11 +149,34 @@ techage.register_node({"techage:signal_lamp_off", "techage:signal_lamp_on"}, {
local node = techage.get_node_lvm(pos) local node = techage.get_node_lvm(pos)
switch_off(pos, node) switch_off(pos, node)
return 0 return 0
elseif topic == 70 then
local node = techage.get_node_lvm(pos)
switch_on(pos, node, nil, payload[1])
return 0
else else
return 2 return 2
end end
end, end,
}) })
end
register_signallamp("techage:signal_lamp",
S("TechAge Signal Lamp"),
{"techage_signal_lamp.png^[colorize:#000000:100"},
{
type = "fixed",
fixed = {
{-6/16, -6/16, -6/16, 6/16, 6/16, 6/16},
{-4/16, -10/16, -4/16, 4/16, -6/16, 4/16},
}
}
)
register_signallamp("techage:signal_lamp2",
S("TechAge Signal Lamp 2 "),
{"techage_signallamp2.png"}
)
minetest.register_craft({ minetest.register_craft({
output = "techage:signal_lamp_off", output = "techage:signal_lamp_off",
@ -144,3 +186,12 @@ minetest.register_craft({
{"", "techage:vacuum_tube", ""}, {"", "techage:vacuum_tube", ""},
}, },
}) })
minetest.register_craft({
output = "techage:signal_lamp2_off",
recipe = {
{"", "default:glass", ""},
{"", "default:torch", ""},
{"", "techage:vacuum_tube", ""},
},
})

View File

@ -631,7 +631,7 @@ Im privaten Modus (private) kann das Terminal nur von Spielern verwendet werden,
### TechAge Signallampe / Signal Lamp ### TechAge Signallampe / Signal Lamp
Die Signallampe kann mit `on`/`off` Kommando ein- bzw. ausgeschaltet werden. Diese Lampe braucht keinen Strom und Die Signallampe kann mit `on`/`off` Kommando ein- bzw. ausgeschaltet werden. Diese Lampe braucht keinen Strom und
kann mit der Spritzpistole aus der Mod "Unified Dyes" farbig gemacht werden. kann mit der Spritzpistole aus der Mod "Unified Dyes" und über Lua/Beduino Kommandos eingefärbt werden.
[ta3_signallamp|image] [ta3_signallamp|image]

View File

@ -629,8 +629,7 @@ In public mode, all players can use the preconfigured keys.
### TechAge Signal Lamp ### TechAge Signal Lamp
The signal lamp can be switched on or off with the `on` / `off` command. This lamp does not need electricity and The signal lamp can be switched on or off with the `on` / `off` command. This lamp does not need electricity and can be colored with the airbrush tool from the mod Unified Dyes" and via Lua/Beduino commands.
can be colored with the airbrush tool of the mod Unified Dyes.
[ta3_signallamp|image] [ta3_signallamp|image]

View File

@ -417,6 +417,7 @@ Please note, that this is not a technical distinction, only a logical.
| "stop" | nil | Stop command for the TA4 Sequencer. | | "stop" | nil | Stop command for the TA4 Sequencer. |
| "gain" | volume | Set volume of the sound block (`volume` is a value between 0 and 1.0) | | "gain" | volume | Set volume of the sound block (`volume` is a value between 0 and 1.0) |
| "sound" | index | Select sound sample of the sound block | | "sound" | index | Select sound sample of the sound block |
| "color" | \<color> | Set the color of the TechAge Signal Lamp and TechAge Signal Lamp 2 (color = 0..255) |
### Server and Terminal Functions ### Server and Terminal Functions

40
textures/generate.py Executable file
View File

@ -0,0 +1,40 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Script to generate the palette PNG file.
#
# Copyright (C) 2022 Joachim Stolberg
# LGPLv2.1+
from PIL import Image
MainColors = [
0x000080, 0x008000, 0x800000, 0x008080, 0x808000, 0x800080,
0x0000FF, 0x00FF00, 0xFF0000, 0x00FFFF, 0xFFFF00, 0xFF00FF,
0x0080FF, 0x8000FF, 0x80FF00, 0x00FF80, 0xFF8000, 0xFF0080,
]
def generate():
img = Image.new("RGB", (18, 15), color='#000000')
# Main colors
for x in range(0,18):
img.putpixel((x, 0), MainColors[x])
# Grey scale
for x in range(0,18):
img.putpixel((x, 1), (x * 15, x * 15, x * 15))
# 216 colors palette
idx = 36
for r in range(0,6):
for g in range(0,6):
for b in range(0,6):
x = idx % 18
y = int(idx / 18)
img.putpixel((x, y), (r * 0x33, g * 0x33, b * 0x33))
idx += 1
img.save("techage_palette256.png", "PNG")
generate()

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B