From ff525c09a4a57eb4c99060824e8738d86f5e4c22 Mon Sep 17 00:00:00 2001 From: OgelGames Date: Fri, 22 Jan 2021 03:47:55 +1100 Subject: [PATCH] Fix wires not connecting to nodes using `digilines` def (#68) --- inventory.lua | 2 +- lcd.lua | 2 +- lightsensor.lua | 2 +- rtc.lua | 2 +- wire_std.lua | 2 +- wires_common.lua | 18 +++++++----------- 6 files changed, 12 insertions(+), 16 deletions(-) diff --git a/inventory.lua b/inventory.lua index 8af786f..287f9a2 100644 --- a/inventory.lua +++ b/inventory.lua @@ -97,7 +97,7 @@ minetest.register_node("digilines:chest", { minetest.get_meta(pos):set_string("channel",fields.channel) end end, - digiline = { + digilines = { receptor = {}, effector = { action = function() end diff --git a/lcd.lua b/lcd.lua index 88b8e47..456a69b 100644 --- a/lcd.lua +++ b/lcd.lua @@ -313,7 +313,7 @@ minetest.register_node("digilines:lcd", { minetest.get_meta(pos):set_string("channel", fields.channel) end end, - digiline = { + digilines = { receptor = {}, effector = { action = on_digiline_receive diff --git a/lightsensor.lua b/lightsensor.lua index 1c7237b..8025acd 100644 --- a/lightsensor.lua +++ b/lightsensor.lua @@ -39,7 +39,7 @@ minetest.register_node("digilines:lightsensor", { groups = {dig_immediate=2}, selection_box = lsensor_selbox, node_box = lsensor_nodebox, - digiline = + digilines = { receptor = {}, effector = { diff --git a/rtc.lua b/rtc.lua index a82f774..cb89178 100644 --- a/rtc.lua +++ b/rtc.lua @@ -35,7 +35,7 @@ minetest.register_node("digilines:rtc", { groups = {dig_immediate=2}, selection_box = rtc_selbox, node_box = rtc_nodebox, - digiline = + digilines = { receptor = {}, effector = { diff --git a/wire_std.lua b/wire_std.lua index 177e795..acb45ea 100644 --- a/wire_std.lua +++ b/wire_std.lua @@ -90,7 +90,7 @@ for zmy=0, 1 do paramtype = "light", paramtype2 = "facedir", sunlight_propagates = true, - digiline = + digilines = { wire = { diff --git a/wires_common.lua b/wires_common.lua index 8ac1d29..b42153d 100644 --- a/wires_common.lua +++ b/wires_common.lua @@ -1,15 +1,12 @@ -minetest.register_on_placenode(function(pos, node) - if minetest.registered_nodes[node.name].digiline then - digilines.update_autoconnect(pos) - end -end) -minetest.register_on_dignode(function(pos, node) - if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].digiline then --- need to make sure that node exists (unknown nodes!) +local function check_and_update(pos, node) + if digilines.getspec(node) then digilines.update_autoconnect(pos) end -end) +end + +minetest.register_on_placenode(check_and_update) +minetest.register_on_dignode(check_and_update) function digilines.update_autoconnect(pos, secondcall) local xppos = {x=pos.x+1, y=pos.y, z=pos.z} @@ -42,8 +39,7 @@ function digilines.update_autoconnect(pos, secondcall) digilines.update_autoconnect(zmympos, true) end - local def = minetest.registered_nodes[minetest.get_node(pos).name] - local digilinespec = def and def.digiline + local digilinespec = digilines.getspec(minetest.get_node(pos)) if not (digilinespec and digilinespec.wire and digilinespec.wire.use_autoconnect) then return nil