added custom overrides, motion-sensors and more...
This commit is contained in:
parent
53466eed17
commit
ff423fc029
11 changed files with 348 additions and 26 deletions
52
tools.lua
52
tools.lua
|
|
@ -23,7 +23,8 @@ minetest.register_tool("smart_light:programmer", {
|
|||
-- LAMPE PASTEN
|
||||
local original = smart_light.shadow_to_original[node.name] or node.name
|
||||
if smart_light.original_to_shadows[original] then
|
||||
smart_light.registry.areas[area].channels[chan] = smart_light.registry.areas[area].channels[chan] or { nodes = {}, last_level = "max" }
|
||||
smart_light.registry.areas[area] = smart_light.registry.areas[area] or { channels = {} }
|
||||
smart_light.registry.areas[area].channels[chan] = smart_light.registry.areas[area].channels[chan] or { nodes = {}, last_level = "max", brightness = "max" }
|
||||
smart_light.registry.areas[area].channels[chan].nodes[pos_str] = true
|
||||
smart_light.save()
|
||||
local n_meta = minetest.get_meta(pos)
|
||||
|
|
@ -50,6 +51,21 @@ minetest.register_tool("smart_light:programmer", {
|
|||
minetest.chat_send_player(name, "PASTE (Schalter): " .. area .. ":" .. chan)
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- NEU: BEWEGUNGSMELDER PASTEN
|
||||
if node.name:sub(1, 25) == "smart_light:motion_sensor" then
|
||||
if not smart_light.registry.areas[area] or not smart_light.registry.areas[area].channels[chan] then
|
||||
minetest.chat_send_player(name, "FEHLER: Ziel-Kanal existiert nicht!")
|
||||
return
|
||||
end
|
||||
local n_meta = minetest.get_meta(pos)
|
||||
n_meta:set_string("sl_area", area)
|
||||
n_meta:set_string("sl_chan", chan)
|
||||
n_meta:set_string("infotext", "Bewegungsmelder: " .. area .. ":" .. chan)
|
||||
minetest.get_node_timer(pos):start(1.5) -- Logik-Timer starten
|
||||
minetest.chat_send_player(name, "PASTE (Sensor): " .. area .. ":" .. chan)
|
||||
return itemstack
|
||||
end
|
||||
end,
|
||||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
|
|
@ -65,17 +81,14 @@ minetest.register_tool("smart_light:programmer", {
|
|||
return itemstack
|
||||
end
|
||||
|
||||
-- SCHALTER SETUP (Beide Dropdowns mit Platzhalter)
|
||||
-- SCHALTER SETUP
|
||||
if node.name:sub(1, 18) == "smart_light:switch" then
|
||||
local n_meta = minetest.get_meta(pos)
|
||||
local curr_area = n_meta:get_string("sl_area")
|
||||
|
||||
local areas_table = {"-- Bitte wählen --"}
|
||||
for a_id, _ in pairs(smart_light.registry.areas) do table.insert(areas_table, a_id) end
|
||||
|
||||
local area_idx = 1
|
||||
for i, v in ipairs(areas_table) do if v == curr_area then area_idx = i end end
|
||||
|
||||
local channels_table = {"-- Bitte wählen --"}
|
||||
if curr_area ~= "" and curr_area ~= "-- Bitte wählen --" and smart_light.registry.areas[curr_area] then
|
||||
local tmp = {}
|
||||
|
|
@ -83,29 +96,50 @@ minetest.register_tool("smart_light:programmer", {
|
|||
table.sort(tmp)
|
||||
for _, c in ipairs(tmp) do table.insert(channels_table, c) end
|
||||
end
|
||||
|
||||
local fs = "size[5,4.5]label[0.5,0.2;Schalter Programmierung]" ..
|
||||
"dropdown[0.5,1.2;4,1;area_sel;" .. table.concat(areas_table, ",") .. ";" .. area_idx .. "]" ..
|
||||
"label[0.5,2.2;Kanal auswählen:]" ..
|
||||
"dropdown[0.5,2.7;4,1;chan_sel;" .. table.concat(channels_table, ",") .. ";1]" ..
|
||||
"button[0.5,3.8;1.5,1;cancel;Abbruch]" ..
|
||||
"button_exit[2.5,3.8;2,1;save_switch;Speichern]"
|
||||
|
||||
minetest.show_formspec(name, "smart_light:prog_sw_" .. minetest.pos_to_string(pos), fs)
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- NEU: BEWEGUNGSMELDER SETUP (Dropdown für Area/Kanal)
|
||||
if node.name:sub(1, 25) == "smart_light:motion_sensor" then
|
||||
local n_meta = minetest.get_meta(pos)
|
||||
local curr_area = n_meta:get_string("sl_area")
|
||||
local areas_table = {"-- Bitte wählen --"}
|
||||
for a_id, _ in pairs(smart_light.registry.areas) do table.insert(areas_table, a_id) end
|
||||
local area_idx = 1
|
||||
for i, v in ipairs(areas_table) do if v == curr_area then area_idx = i end end
|
||||
local channels_table = {"-- Bitte wählen --"}
|
||||
if curr_area ~= "" and curr_area ~= "-- Bitte wählen --" and smart_light.registry.areas[curr_area] then
|
||||
local tmp = {}
|
||||
for c_id, _ in pairs(smart_light.registry.areas[curr_area].channels) do table.insert(tmp, c_id) end
|
||||
table.sort(tmp)
|
||||
for _, c in ipairs(tmp) do table.insert(channels_table, c) end
|
||||
end
|
||||
local fs = "size[5,4.5]label[0.5,0.2;Sensor Kanal-Setup]" ..
|
||||
"dropdown[0.5,1.2;4,1;area_sel;" .. table.concat(areas_table, ",") .. ";" .. area_idx .. "]" ..
|
||||
"label[0.5,2.2;Kanal auswählen:]" ..
|
||||
"dropdown[0.5,2.7;4,1;chan_sel;" .. table.concat(channels_table, ",") .. ";1]" ..
|
||||
"button[0.5,3.8;1.5,1;cancel;Abbruch]" ..
|
||||
"button_exit[2.5,3.8;2,1;save_ms;Speichern]"
|
||||
minetest.show_formspec(name, "smart_light:prog_ms_" .. minetest.pos_to_string(pos), fs)
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- LAMPEN SETUP
|
||||
local original = smart_light.shadow_to_original[node.name] or node.name
|
||||
if not smart_light.original_to_shadows[original] then return end
|
||||
local n_meta = minetest.get_meta(pos)
|
||||
local curr_area, curr_chan = n_meta:get_string("sl_area"), n_meta:get_string("sl_chan")
|
||||
|
||||
local areas_table = {"-- Bitte wählen --"}
|
||||
for a_id, _ in pairs(smart_light.registry.areas) do table.insert(areas_table, a_id) end
|
||||
local area_idx = 1
|
||||
for i, v in ipairs(areas_table) do if v == curr_area then area_idx = i end end
|
||||
|
||||
local fs = "size[5,4.5]label[0.5,0.2;Licht Programmierung]" ..
|
||||
"dropdown[0.5,1.2;4,1;area_sel;" .. table.concat(areas_table, ",") .. ";" .. area_idx .. "]" ..
|
||||
"field[0.8,2.5;4,1;chan_in;Channel ID;" .. curr_chan .. "]" ..
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue