From ed3035a18368a6744b9dd9fd222b35821efdbf00 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Sat, 31 Mar 2018 19:03:53 +0200 Subject: [PATCH] V1.04, Source maintenance, minor issues fixed, Unifieddyes support for Color Lamp added --- .gitignore | 3 +++ smartline/controller.lua | 2 +- smartline/display.lua | 2 +- smartline/playerdetector.lua | 2 +- smartline/repeater.lua | 2 +- smartline/sequencer.lua | 4 ++-- smartline/signaltower.lua | 2 +- smartline/timer.lua | 2 +- tubelib/api.md | 1 - tubelib/button.lua | 2 +- tubelib/command.lua | 28 +++++++++----------------- tubelib/lamp.lua | 2 +- tubelib_addons2/accesscontrol.lua | 2 +- tubelib_addons2/colorlamp.lua | 2 +- tubelib_addons2/colorlamp_ud.lua | 2 +- tubelib_addons2/doorblock.lua | 2 +- tubelib_addons2/gateblock.lua | 2 +- tubelib_addons2/init.lua | 1 + tubelib_addons2/mesecons_converter.lua | 2 +- tubelib_addons2/repeater.lua | 2 +- tubelib_addons2/sequencer.lua | 2 +- 21 files changed, 32 insertions(+), 37 deletions(-) diff --git a/.gitignore b/.gitignore index 6fd0a37..34ff104 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ luac.out *.x86_64 *.hex +.buildpath +.project +org.eclipse.* diff --git a/smartline/controller.lua b/smartline/controller.lua index bdd6c41..81603ac 100644 --- a/smartline/controller.lua +++ b/smartline/controller.lua @@ -813,7 +813,7 @@ minetest.register_node("smartline:controller", { after_place_node = function(pos, placer) local meta = minetest.get_meta(pos) - local number = tubelib.add_node(pos) + local number = tubelib.add_node(pos, "smartline:controller") local fs_data = {} meta:set_string("fs_data", minetest.serialize(fs_data)) meta:set_string("owner", placer:get_player_name()) diff --git a/smartline/display.lua b/smartline/display.lua index 9db68c7..6ae1f93 100644 --- a/smartline/display.lua +++ b/smartline/display.lua @@ -51,7 +51,7 @@ minetest.register_node("smartline:display", { }, after_place_node = function(pos, placer) - local number = tubelib.add_node(pos) + local number = tubelib.add_node(pos, "smartline:display") local meta = minetest.get_meta(pos) meta:set_string("number", number) meta:set_string("text", " \n \nMinetest\nSmartLine Tools\n \nDisplay\nNumber: "..number) diff --git a/smartline/playerdetector.lua b/smartline/playerdetector.lua index 7f25d0a..26a7dac 100644 --- a/smartline/playerdetector.lua +++ b/smartline/playerdetector.lua @@ -121,7 +121,7 @@ minetest.register_node("smartline:playerdetector", { }, }, after_place_node = function(pos, placer) - local number = tubelib.add_node(pos) + local number = tubelib.add_node(pos, "smartline:playerdetector") local meta = minetest.get_meta(pos) meta:set_string("number", number) local numbers = meta:get_string("numbers") or "" diff --git a/smartline/repeater.lua b/smartline/repeater.lua index cebc841..b44d604 100644 --- a/smartline/repeater.lua +++ b/smartline/repeater.lua @@ -45,7 +45,7 @@ minetest.register_node("smartline:repeater", { after_place_node = function(pos, placer) local meta = minetest.get_meta(pos) - local own_number = tubelib.add_node(pos) + local own_number = tubelib.add_node(pos, "smartline:repeater") meta:set_string("own_number", own_number) meta:set_string("formspec", formspec(meta)) meta:set_string("infotext", "SmartLine Repeater "..own_number..": not connected") diff --git a/smartline/sequencer.lua b/smartline/sequencer.lua index 65eb37a..8e8b19c 100644 --- a/smartline/sequencer.lua +++ b/smartline/sequencer.lua @@ -222,7 +222,7 @@ minetest.register_node("smartline:sequencer", { }, after_place_node = function(pos, placer) local meta = minetest.get_meta(pos) - local number = tubelib.add_node(pos) + local number = tubelib.add_node(pos, "smartline:sequencer") local rules = {} for idx = 1,NUM_SLOTS do rules[idx] = {offs = "", num = "", act = 1} @@ -282,4 +282,4 @@ tubelib.register_node("smartline:sequencer", {}, { meta:set_int("endless", 0) end end, -}) \ No newline at end of file +}) diff --git a/smartline/signaltower.lua b/smartline/signaltower.lua index 9d7ea72..9af2555 100644 --- a/smartline/signaltower.lua +++ b/smartline/signaltower.lua @@ -44,7 +44,7 @@ minetest.register_node("smartline:signaltower", { }, after_place_node = function(pos, placer) - local number = tubelib.add_node(pos) + local number = tubelib.add_node(pos, "smartline:signaltower") local meta = minetest.get_meta(pos) meta:set_string("state", "off") meta:set_string("infotext", "SmartLine Signal Tower "..number) diff --git a/smartline/timer.lua b/smartline/timer.lua index fc84c36..0053b15 100644 --- a/smartline/timer.lua +++ b/smartline/timer.lua @@ -152,7 +152,7 @@ minetest.register_node("smartline:timer", { local numbers = {"0000","","","","",""} local actions = {"","","","","",""} local done = {false,false,false,false,false,false} - local own_num = tubelib.add_node(pos) + local own_num = tubelib.add_node(pos, "smartline:timer") meta:set_string("own_num", own_num) meta:set_string("placer_name", placer:get_player_name()) meta:set_string("events", minetest.serialize(events)) diff --git a/tubelib/api.md b/tubelib/api.md index a671391..2538ae6 100644 --- a/tubelib/api.md +++ b/tubelib/api.md @@ -126,7 +126,6 @@ Parameters: The function is used to register the nodes position for the communication node number and to update the tube surrounding. `pos` the node position, `name` is the node name. -If 'name' is nil, the tube surrounding is not updated, which should be used for nodes without tube connection. diff --git a/tubelib/button.lua b/tubelib/button.lua index 78767f1..d6fe0b6 100644 --- a/tubelib/button.lua +++ b/tubelib/button.lua @@ -70,7 +70,7 @@ minetest.register_node("tubelib:button", { after_place_node = function(pos, placer) local meta = minetest.get_meta(pos) - local own_num = tubelib.add_node(pos) + local own_num = tubelib.add_node(pos, "tubelib:button") meta:set_string("own_num", own_num) meta:set_string("formspec", "size[5,6]".. "dropdown[0.2,0;3;type;switch,button 2s,button 4s,button 8s,button 16s;1]".. diff --git a/tubelib/command.lua b/tubelib/command.lua index ef6f269..d0091a7 100644 --- a/tubelib/command.lua +++ b/tubelib/command.lua @@ -161,19 +161,15 @@ end -- Add node to the tubelib lists and update the tube surrounding. -- Function determines and returns the node position number, -- needed for message communication. --- If 'name' is nil, the tube surrounding is not updated, --- which should be used for nodes without tube connection. function tubelib.add_node(pos, name) -- store position local number = get_number(pos) - if name then - Number2Pos[number] = { - pos = pos, - name = name, - } - -- update surrounding tubes - tubelib.update_tubes(pos) - end + Number2Pos[number] = { + pos = pos, + name = name, + } + -- update surrounding tubes + tubelib.update_tubes(pos) return number end @@ -226,10 +222,8 @@ function tubelib.send_message(numbers, placer_name, clicker_name, topic, payload local data = Number2Pos[num] if placer_name and not minetest.is_protected(data.pos, placer_name) then if clicker_name == nil or not minetest.is_protected(data.pos, clicker_name) then - if data and data.name then - if tubelib_NodeDef[data.name] and tubelib_NodeDef[data.name].on_recv_message then - tubelib_NodeDef[data.name].on_recv_message(data.pos, topic, payload) - end + if tubelib_NodeDef[data.name] and tubelib_NodeDef[data.name].on_recv_message then + tubelib_NodeDef[data.name].on_recv_message(data.pos, topic, payload) end end end @@ -240,10 +234,8 @@ end function tubelib.send_request(number, topic, payload) if Number2Pos[number] and Number2Pos[number].name then local data = Number2Pos[number] - if data and data.name then - if tubelib_NodeDef[data.name] and tubelib_NodeDef[data.name].on_recv_message then - return tubelib_NodeDef[data.name].on_recv_message(data.pos, topic, payload) - end + if tubelib_NodeDef[data.name] and tubelib_NodeDef[data.name].on_recv_message then + return tubelib_NodeDef[data.name].on_recv_message(data.pos, topic, payload) end end return false diff --git a/tubelib/lamp.lua b/tubelib/lamp.lua index 2264496..a0129d7 100644 --- a/tubelib/lamp.lua +++ b/tubelib/lamp.lua @@ -35,7 +35,7 @@ minetest.register_node("tubelib:lamp", { }, after_place_node = function(pos, placer) - local number = tubelib.add_node(pos) -- <<=== tubelib + local number = tubelib.add_node(pos, "tubelib:lamp") -- <<=== tubelib local meta = minetest.get_meta(pos) meta:set_string("infotext", "Tubelib Lamp "..number) end, diff --git a/tubelib_addons2/accesscontrol.lua b/tubelib_addons2/accesscontrol.lua index 97fae3f..9790c7b 100644 --- a/tubelib_addons2/accesscontrol.lua +++ b/tubelib_addons2/accesscontrol.lua @@ -79,7 +79,7 @@ minetest.register_node("tubelib_addons2:accesscontrol", { }, after_place_node = function(pos, placer) - local number = tubelib.add_node(pos) + local number = tubelib.add_node(pos, "tubelib_addons2:accesscontrol") local meta = minetest.get_meta(pos) meta:set_string("number", number) local numbers = meta:get_string("numbers") or "" diff --git a/tubelib_addons2/colorlamp.lua b/tubelib_addons2/colorlamp.lua index 15db2d9..46c2412 100644 --- a/tubelib_addons2/colorlamp.lua +++ b/tubelib_addons2/colorlamp.lua @@ -36,7 +36,7 @@ minetest.register_node("tubelib_addons2:lamp", { tiles = {"tubelib_addons2_lamp.png^[colorize:#000000:100"}, after_place_node = function(pos, placer) - local number = tubelib.add_node(pos) + local number = tubelib.add_node(pos, "tubelib_addons2:lamp") local meta = minetest.get_meta(pos) meta:set_int("number", number) switch_node(pos, "", placer) diff --git a/tubelib_addons2/colorlamp_ud.lua b/tubelib_addons2/colorlamp_ud.lua index 1b6d5c6..e45505d 100644 --- a/tubelib_addons2/colorlamp_ud.lua +++ b/tubelib_addons2/colorlamp_ud.lua @@ -31,7 +31,7 @@ minetest.register_node("tubelib_addons2:lamp_off", { tiles = {"tubelib_addons2_lamp.png^[colorize:#000000:100"}, after_place_node = function(pos, placer, itemstack, pointed_thing) - local number = tubelib.add_node(pos) + local number = tubelib.add_node(pos, "tubelib_addons2:lamp_off") local meta = minetest.get_meta(pos) meta:set_string("infotext", "Tubelib Color Lamp "..number) unifieddyes.recolor_on_place(pos, placer, itemstack, pointed_thing) diff --git a/tubelib_addons2/doorblock.lua b/tubelib_addons2/doorblock.lua index 6ef60da..0eca8ee 100644 --- a/tubelib_addons2/doorblock.lua +++ b/tubelib_addons2/doorblock.lua @@ -52,7 +52,7 @@ for idx,pgn in ipairs(tPgns) do after_place_node = function(pos, placer) local meta = minetest.get_meta(pos) local node = minetest.get_node(pos) - local number = tubelib.add_node(pos) + local number = tubelib.add_node(pos, "tubelib_addons2:doorblock"..idx) tubelib.set_data(number, "facedir", node.param2) meta:set_string("number", number) meta:set_string("infotext", "Tubelib Door Block "..number) diff --git a/tubelib_addons2/gateblock.lua b/tubelib_addons2/gateblock.lua index 6058de9..9e12865 100644 --- a/tubelib_addons2/gateblock.lua +++ b/tubelib_addons2/gateblock.lua @@ -36,7 +36,7 @@ for idx,pgn in ipairs(tPgns) do after_place_node = function(pos, placer) local meta = minetest.get_meta(pos) local node = minetest.get_node(pos) - local number = tubelib.add_node(pos) + local number = tubelib.add_node(pos, "tubelib_addons2:gateblock"..idx) meta:set_string("infotext", "Tubelib Gate Block "..number) meta:set_string("formspec", "size[3,2]".. "label[0,0;Select texture]".. diff --git a/tubelib_addons2/init.lua b/tubelib_addons2/init.lua index ed11b5a..1d2a888 100644 --- a/tubelib_addons2/init.lua +++ b/tubelib_addons2/init.lua @@ -17,6 +17,7 @@ dofile(minetest.get_modpath("tubelib_addons2") .. "/doorblock.lua") dofile(minetest.get_modpath("tubelib_addons2") .. "/repeater.lua") dofile(minetest.get_modpath("tubelib_addons2") .. "/programmer.lua") dofile(minetest.get_modpath("tubelib_addons2") .. "/accesscontrol.lua") +dofile(minetest.get_modpath("tubelib_addons2") .. "/streetlamp.lua") if minetest.get_modpath("mesecons") and mesecon then dofile(minetest.get_modpath("tubelib_addons2") .. "/mesecons_converter.lua") end diff --git a/tubelib_addons2/mesecons_converter.lua b/tubelib_addons2/mesecons_converter.lua index 59aa48e..b78768e 100644 --- a/tubelib_addons2/mesecons_converter.lua +++ b/tubelib_addons2/mesecons_converter.lua @@ -52,7 +52,7 @@ minetest.register_node("tubelib_addons2:mesecons_converter", { after_place_node = function(pos, placer) local meta = minetest.get_meta(pos) - local own_number = tubelib.add_node(pos) + local own_number = tubelib.add_node(pos, "tubelib_addons2:mesecons_converter") meta:set_string("own_number", own_number) meta:set_string("formspec", formspec(meta)) meta:set_string("infotext", "Tubelib Mesecons Converter "..own_number..": not connected") diff --git a/tubelib_addons2/repeater.lua b/tubelib_addons2/repeater.lua index f970728..07d5873 100644 --- a/tubelib_addons2/repeater.lua +++ b/tubelib_addons2/repeater.lua @@ -32,7 +32,7 @@ minetest.register_node("tubelib_addons2:repeater", { after_place_node = function(pos, placer) local meta = minetest.get_meta(pos) - local own_number = tubelib.add_node(pos) + local own_number = tubelib.add_node(pos, "tubelib_addons2:repeater") meta:set_string("own_number", own_number) meta:set_string("formspec", formspec(meta)) meta:set_string("infotext", "Tubelib Repeater "..own_number..": not connected") diff --git a/tubelib_addons2/sequencer.lua b/tubelib_addons2/sequencer.lua index 30ecc55..f06d018 100644 --- a/tubelib_addons2/sequencer.lua +++ b/tubelib_addons2/sequencer.lua @@ -201,7 +201,7 @@ minetest.register_node("tubelib_addons2:sequencer", { after_place_node = function(pos, placer) local meta = minetest.get_meta(pos) - local number = tubelib.add_node(pos) + local number = tubelib.add_node(pos, "tubelib_addons2:sequencer") local rules = {} for idx = 1,NUM_SLOTS do rules[idx] = {offs = "", num = "", act = 1}