mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-25 16:43:50 +01:00
parent
e1c63f93a5
commit
dc790d0224
@ -3,7 +3,7 @@
|
|||||||
SmartLine
|
SmartLine
|
||||||
=========
|
=========
|
||||||
|
|
||||||
Copyright (C) 2017-2020 Joachim Stolberg
|
Copyright (C) 2017-2023 Joachim Stolberg
|
||||||
|
|
||||||
AGPL v3
|
AGPL v3
|
||||||
See LICENSE.txt for more information
|
See LICENSE.txt for more information
|
||||||
@ -19,10 +19,12 @@ local S = smartline.S
|
|||||||
|
|
||||||
local CYCLE_TIME = 1
|
local CYCLE_TIME = 1
|
||||||
|
|
||||||
local tStates = {stopped = 0, running = 0, standby = 1, blocked = 2, fault = 3, defect = 4}
|
-- The numbering seems strange here, but I had to add the "running" state
|
||||||
local tDropdownPos = {["1 standby"] = 1, ["2 blocked"] = 2 , ["3 fault"] = 3, ["4 defect"] = 4}
|
-- afterwards without changing the behavior of the block.
|
||||||
local lStates = {[0] = "stopped", "standby", "blocked", "fault", "defect"}
|
local tStates = {stopped = 0, running = 1, standby = 2, blocked = 3, fault = 4, defect = 5}
|
||||||
|
local tDropdownPos = {["1 standby"] = 1, ["2 blocked"] = 2, ["3 fault"] = 3, ["4 defect"] = 4}
|
||||||
|
local lStates = {[0] = "stopped", "running", "standby", "blocked", "fault", "defect"}
|
||||||
|
|
||||||
local function formspec(meta)
|
local function formspec(meta)
|
||||||
local poll_numbers = meta:get_string("poll_numbers")
|
local poll_numbers = meta:get_string("poll_numbers")
|
||||||
local event_number = meta:get_string("event_number")
|
local event_number = meta:get_string("event_number")
|
||||||
@ -48,7 +50,7 @@ local function send_event(meta)
|
|||||||
local severity = meta:get_int("dropdown_pos")
|
local severity = meta:get_int("dropdown_pos")
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
local own_number = meta:get_string("own_number")
|
local own_number = meta:get_string("own_number")
|
||||||
if state >= severity then
|
if state > severity then
|
||||||
tubelib.send_message(event_number, owner, nil, "on", own_number)
|
tubelib.send_message(event_number, owner, nil, "on", own_number)
|
||||||
else
|
else
|
||||||
tubelib.send_message(event_number, owner, nil, "off", own_number)
|
tubelib.send_message(event_number, owner, nil, "off", own_number)
|
||||||
|
@ -40,6 +40,7 @@ minetest.register_node("tubelib:lamp", {
|
|||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local number = tubelib.add_node(pos, "tubelib:lamp") -- <<=== tubelib
|
local number = tubelib.add_node(pos, "tubelib:lamp") -- <<=== tubelib
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("number", number)
|
||||||
meta:set_string("infotext", S("Tubelib Lamp").." "..number)
|
meta:set_string("infotext", S("Tubelib Lamp").." "..number)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ minetest.register_node("tubelib_addons2:lamp", {
|
|||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local number = tubelib.add_node(pos, "tubelib_addons2:lamp")
|
local number = tubelib.add_node(pos, "tubelib_addons2:lamp")
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_int("number", number)
|
meta:set_string("number", number)
|
||||||
switch_node(pos, "", placer)
|
switch_node(pos, "", placer)
|
||||||
meta:set_string("formspec", "size[3,2]"..
|
meta:set_string("formspec", "size[3,2]"..
|
||||||
"label[0,0;Select color]"..
|
"label[0,0;Select color]"..
|
||||||
@ -77,18 +77,6 @@ minetest.register_node("tubelib_addons2:lamp", {
|
|||||||
on_blast = function() end,
|
on_blast = function() end,
|
||||||
})
|
})
|
||||||
|
|
||||||
tubelib.register_node("tubelib_addons2:lamp", {}, {
|
|
||||||
on_recv_message = function(pos, topic, payload)
|
|
||||||
if topic == "on" then
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
switch_node(pos, meta:get_int("color") or "", nil)
|
|
||||||
elseif topic == "off" then
|
|
||||||
switch_node(pos, "", nil)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "tubelib_addons2:lamp 2",
|
output = "tubelib_addons2:lamp 2",
|
||||||
recipe = {
|
recipe = {
|
||||||
@ -98,7 +86,9 @@ minetest.register_craft({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local NodeNames = {}
|
||||||
for idx,color in ipairs(tColors) do
|
for idx,color in ipairs(tColors) do
|
||||||
|
NodeNames[idx] = "tubelib_addons2:lamp"..idx
|
||||||
minetest.register_node("tubelib_addons2:lamp"..idx, {
|
minetest.register_node("tubelib_addons2:lamp"..idx, {
|
||||||
description = S("Tubelib Color Lamp"),
|
description = S("Tubelib Color Lamp"),
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -132,3 +122,14 @@ for idx,color in ipairs(tColors) do
|
|||||||
on_blast = function() end,
|
on_blast = function() end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tubelib.register_node("tubelib_addons2:lamp", NodeNames, {
|
||||||
|
on_recv_message = function(pos, topic, payload)
|
||||||
|
if topic == "on" then
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
switch_node(pos, meta:get_int("color") or "", nil)
|
||||||
|
elseif topic == "off" then
|
||||||
|
switch_node(pos, "", nil)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user