From 6ad2c9f568c52297f82316d9b8528dd17962b81b Mon Sep 17 00:00:00 2001 From: Pedro Gimeno Date: Thu, 6 Jun 2019 23:13:53 +0200 Subject: [PATCH 1/3] Prevent another crash if minetest crashes during startup --- luaentity.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/luaentity.lua b/luaentity.lua index c11c030..8385264 100644 --- a/luaentity.lua +++ b/luaentity.lua @@ -46,6 +46,11 @@ local function read_entities() end local function write_entities() + if not luaentity.entities then + -- This can happen if crashing on startup, causing another error that + -- masks the original one. Return gracefully in that case instead. + return + end for _, entity in pairs(luaentity.entities) do setmetatable(entity, nil) for _, attached in pairs(entity._attached_entities) do From d5fe93345694f2d24f3f9006df5d05be5f9fe298 Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Mon, 23 Sep 2019 15:36:33 -0400 Subject: [PATCH 2/3] use default metal sounds on all pipes and pipe devices --- devices.lua | 32 ++++++++++++++++---------------- pipes.lua | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/devices.lua b/devices.lua index 2ace81f..340fc4d 100644 --- a/devices.lua +++ b/devices.lua @@ -142,7 +142,7 @@ for s in ipairs(states) do paramtype = "light", paramtype2 = "facedir", groups = dgroups, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, pipe_connections = { top = 1 }, after_place_node = function(pos) @@ -194,7 +194,7 @@ for s in ipairs(states) do fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } }, groups = dgroups, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, on_place = pipeworks.rotate_on_place, after_dig_node = function(pos) @@ -240,7 +240,7 @@ minetest.register_node(nodename_valve_loaded, { fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } }, groups = {snappy=3, pipe=1, not_in_creative_inventory=1}, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, on_place = pipeworks.rotate_on_place, after_dig_node = function(pos) @@ -289,7 +289,7 @@ minetest.register_node("pipeworks:grating", { sunlight_propagates = true, paramtype = "light", groups = {snappy=3, pipe=1}, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, pipe_connections = { top = 1 }, after_place_node = function(pos) @@ -313,7 +313,7 @@ minetest.register_node(nodename_spigot_empty, { paramtype = "light", paramtype2 = "facedir", groups = {snappy=3, pipe=1}, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, pipe_connections = { left=1, right=1, front=1, back=1, left_param2 = 3, right_param2 = 1, front_param2 = 2, back_param2 = 0 }, @@ -355,7 +355,7 @@ minetest.register_node(nodename_spigot_loaded, { paramtype = "light", paramtype2 = "facedir", groups = {snappy=3, pipe=1, not_in_creative_inventory=1}, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, pipe_connections = { left=1, right=1, front=1, back=1, left_param2 = 3, right_param2 = 1, front_param2 = 2, back_param2 = 0 }, @@ -409,7 +409,7 @@ minetest.register_node(nodename_panel_empty, { paramtype = "light", paramtype2 = "facedir", groups = {snappy=3, pipe=1}, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, on_place = pipeworks.rotate_on_place, after_dig_node = function(pos) @@ -429,7 +429,7 @@ minetest.register_node(nodename_panel_loaded, { paramtype = "light", paramtype2 = "facedir", groups = {snappy=3, pipe=1, not_in_creative_inventory=1}, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, on_place = pipeworks.rotate_on_place, after_dig_node = function(pos) @@ -456,7 +456,7 @@ minetest.register_node(nodename_sensor_empty, { paramtype = "light", paramtype2 = "facedir", groups = {snappy=3, pipe=1}, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, on_place = pipeworks.rotate_on_place, after_dig_node = function(pos) @@ -495,7 +495,7 @@ minetest.register_node(nodename_sensor_loaded, { paramtype = "light", paramtype2 = "facedir", groups = {snappy=3, pipe=1, not_in_creative_inventory=1}, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, on_place = pipeworks.rotate_on_place, after_dig_node = function(pos) @@ -560,7 +560,7 @@ for fill = 0, 10 do paramtype = "light", paramtype2 = "facedir", groups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1}, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, drop = "pipeworks:storage_tank_0", pipe_connections = { top = 1, bottom = 1}, @@ -588,7 +588,7 @@ for fill = 0, 10 do paramtype = "light", paramtype2 = "facedir", groups = sgroups, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, drop = "pipeworks:storage_tank_0", pipe_connections = { top = 1, bottom = 1}, @@ -614,7 +614,7 @@ minetest.register_node(nodename_fountain_empty, { sunlight_propagates = true, paramtype = "light", groups = {snappy=3, pipe=1}, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, pipe_connections = { bottom = 1 }, after_place_node = function(pos) @@ -648,7 +648,7 @@ minetest.register_node(nodename_fountain_loaded, { sunlight_propagates = true, paramtype = "light", groups = {snappy=3, pipe=1, not_in_creative_inventory=1}, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, pipe_connections = { bottom = 1 }, after_place_node = function(pos) @@ -698,7 +698,7 @@ minetest.register_node(nodename_sp_empty, { paramtype = "light", paramtype2 = "facedir", groups = {snappy=3, pipe=1}, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, on_place = pipeworks.rotate_on_place, after_dig_node = function(pos) @@ -718,7 +718,7 @@ minetest.register_node(nodename_sp_loaded, { paramtype = "light", paramtype2 = "facedir", groups = {snappy=3, pipe=1, not_in_creative_inventory=1}, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, on_place = pipeworks.rotate_on_place, after_dig_node = function(pos) diff --git a/pipes.lua b/pipes.lua index 82fadb1..04988ca 100644 --- a/pipes.lua +++ b/pipes.lua @@ -73,7 +73,7 @@ for index, connects in ipairs(cconnects) do fixed = outsel }, groups = pgroups, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, drop = "pipeworks:pipe_1_empty", after_place_node = function(pos) @@ -104,7 +104,7 @@ for index, connects in ipairs(cconnects) do fixed = outsel }, groups = pgroups, - sounds = default.node_sound_wood_defaults(), + sounds = default.node_sound_metal_defaults(), walkable = true, drop = "pipeworks:pipe_1_empty", after_place_node = function(pos) From 75cfac34e69aabb07c5f8b288c98c1e1164685bf Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Mon, 23 Sep 2019 12:21:54 -0400 Subject: [PATCH 3/3] add signs_lib placement rules only works on signs_lib commit dcdee222 or later. --- depends.txt | 1 + devices.lua | 8 +- init.lua | 4 + pipes.lua | 10 +- routing_tubes.lua | 2 + signs_compat.lua | 241 ++++++++++++++++++++++++++++++++++++++++++ tube_registration.lua | 5 +- 7 files changed, 266 insertions(+), 5 deletions(-) create mode 100644 signs_compat.lua diff --git a/depends.txt b/depends.txt index d84e224..efa0b33 100644 --- a/depends.txt +++ b/depends.txt @@ -4,3 +4,4 @@ screwdriver mesecons? mesecons_mvps? digilines? +signs_lib? diff --git a/devices.lua b/devices.lua index 340fc4d..3d23210 100644 --- a/devices.lua +++ b/devices.lua @@ -706,7 +706,9 @@ minetest.register_node(nodename_sp_empty, { end, selection_box = sp_cbox, collision_box = sp_cbox, - on_rotate = pipeworks.fix_after_rotation + on_rotate = pipeworks.fix_after_rotation, + check_for_pole = pipeworks.check_for_vert_pipe, + check_for_horiz_pole = pipeworks.check_for_horiz_pipe }) local nodename_sp_loaded = "pipeworks:straight_pipe_loaded" @@ -727,7 +729,9 @@ minetest.register_node(nodename_sp_loaded, { selection_box = sp_cbox, collision_box = sp_cbox, drop = "pipeworks:straight_pipe_empty", - on_rotate = pipeworks.fix_after_rotation + on_rotate = pipeworks.fix_after_rotation, + check_for_pole = pipeworks.check_for_vert_pipe, + check_for_horiz_pole = pipeworks.check_for_horiz_pipe }) new_flow_logic_register.directional_horizonal_rotate(nodename_sp_empty, true) diff --git a/init.lua b/init.lua index 445a8d4..ed93dd5 100644 --- a/init.lua +++ b/init.lua @@ -102,6 +102,10 @@ if pipeworks.toggles.finite_water == nil then dofile(pipeworks.modpath.."/autodetect-finite-water.lua") end +if minetest.get_modpath("signs_lib") then + dofile(pipeworks.modpath.."/signs_compat.lua") +end + dofile(pipeworks.modpath.."/common.lua") dofile(pipeworks.modpath.."/models.lua") dofile(pipeworks.modpath.."/autoplace_pipes.lua") diff --git a/pipes.lua b/pipes.lua index 04988ca..3201d79 100644 --- a/pipes.lua +++ b/pipes.lua @@ -82,7 +82,10 @@ for index, connects in ipairs(cconnects) do after_dig_node = function(pos) pipeworks.scan_for_pipe_objects(pos) end, - on_rotate = false + on_rotate = false, + check_for_pole = pipeworks.check_for_vert_pipe, + check_for_horiz_pole = pipeworks.check_for_horiz_pipe, + pipenumber = index }) local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1} @@ -114,7 +117,10 @@ for index, connects in ipairs(cconnects) do after_dig_node = function(pos) pipeworks.scan_for_pipe_objects(pos) end, - on_rotate = false + on_rotate = false, + check_for_pole = pipeworks.check_for_vert_pipe, + check_for_horiz_pole = pipeworks.check_for_horiz_pipe, + pipenumber = index }) local emptypipe = "pipeworks:pipe_"..index.."_empty" diff --git a/routing_tubes.lua b/routing_tubes.lua index 45fcea8..3a69c0a 100644 --- a/routing_tubes.lua +++ b/routing_tubes.lua @@ -162,6 +162,8 @@ if pipeworks.enable_one_way_tube then after_place_node = pipeworks.after_place, after_dig_node = pipeworks.after_dig, on_rotate = pipeworks.on_rotate, + check_for_pole = pipeworks.check_for_vert_tube, + check_for_horiz_pole = pipeworks.check_for_horiz_tube }) minetest.register_craft({ output = "pipeworks:one_way_tube 2", diff --git a/signs_compat.lua b/signs_compat.lua new file mode 100644 index 0000000..cf86f70 --- /dev/null +++ b/signs_compat.lua @@ -0,0 +1,241 @@ +-- This file adds placement rules for signs_lib, if present + +local spv = { + [4] = true, + [6] = true, + [8] = true, + [10] = true, + [13] = true, + [15] = true, + [17] = true, + [19] = true +} + +local sphns = { + [1] = true, + [3] = true, + [5] = true, + [7] = true, + [9] = true, + [11] = true, + [21] = true, + [23] = true +} + +local sphew = { + [0] = true, + [2] = true, + [12] = true, + [14] = true, + [16] = true, + [18] = true, + [20] = true, + [22] = true +} + +local owtv = { + [5] = true, + [7] = true, + [9] = true, + [11] = true, + [12] = true, + [14] = true, + [16] = true, + [18] = true +} + +local owtns = { + [0] = true, + [2] = true, + [4] = true, + [6] = true, + [8] = true, + [10] = true, + [20] = true, + [22] = true +} + +local owtew = { + [1] = true, + [3] = true, + [13] = true, + [15] = true, + [17] = true, + [19] = true, + [21] = true, + [23] = true +} + +local vert_n = { + [3] = {[5] = true}, + [6] = {[9] = true, [12] = true, [16] = true}, + [7] = {[9] = true, [11] = true}, +} + +local vert_e = { + [3] = {[5] = true}, + [6] = {[5] = true, [9] = true, [16] = true}, + [7] = {[7] = true, [11] = true}, +} + +local vert_s = { + [3] = {[5] = true}, + [6] = {[5] = true, [12] = true, [16] = true}, + [7] = {[5] = true, [7] = true}, +} + +local vert_w = { + [3] = {[5] = true}, + [6] = {[5] = true, [9] = true, [12] = true}, + [7] = {[5] = true, [9] = true}, +} + +local horiz_n = { + [3] = {[0] = true}, + [6] = {[0] = true, [4] = true, [20] = true}, + [7] = {[2] = true, [10] = true}, + [8] = {[0] = true}, + [9] = {[2] = true}, +} + +local horiz_e = { + [3] = {[1] = true}, + [6] = {[1] = true, [17] = true, [21] = true}, + [7] = {[3] = true, [19] = true}, + [8] = {[1] = true}, + [9] = {[3] = true}, +} + +local horiz_s = { + [3] = {[0] = true}, + [6] = {[0] = true, [8] = true, [20] = true}, + [7] = {[0] = true, [4] = true}, + [8] = {[0] = true}, + [9] = {[0] = true}, +} + +local horiz_w = { + [3] = {[1] = true}, + [6] = {[1] = true, [13] = true, [21] = true}, + [7] = {[1] = true, [13] = true}, + [8] = {[1] = true}, + [9] = {[1] = true}, +} + +local function get_sign_dir(node, def) + if (node.param2 == 4 and def.paramtype2 == "wallmounted") + or (node.param2 == 0 and def.paramtype2 ~= "wallmounted") then + return {["N"] = true} + elseif (node.param2 == 2 and def.paramtype2 == "wallmounted") + or (node.param2 == 1 and def.paramtype2 ~= "wallmounted") then + return {["E"] = true} + elseif (node.param2 == 5 and def.paramtype2 == "wallmounted") + or (node.param2 == 2 and def.paramtype2 ~= "wallmounted") then + return {["S"] = true} + elseif node.param2 == 3 then + return {["W"] = true} + end + return {} +end + +--[[ +In the functions below: + + pos: the (real) position of the placed sign + node: the sign node itself + def: its definition + + ppos: the position of the pointed node (pipe/tube) + pnode: the node itself + pdef: its definition + +--]] + + +-- pipes + +function pipeworks.check_for_vert_pipe(pos, node, def, ppos, pnode, pdef) + local signdir = get_sign_dir(node, def) + local pipenumber = pdef.pipenumber + local pipedir = pnode.param2 + if string.find(pnode.name, "straight_pipe") and spv[pipedir] then + return true + elseif signdir["N"] and vert_n[pipenumber] and vert_n[pipenumber][pipedir] then + return true + elseif signdir["E"] and vert_e[pipenumber] and vert_e[pipenumber][pipedir] then + return true + elseif signdir["S"] and vert_s[pipenumber] and vert_s[pipenumber][pipedir] then + return true + elseif signdir["W"] and vert_w[pipenumber] and vert_w[pipenumber][pipedir] then + return true + end +end + +function pipeworks.check_for_horiz_pipe(pos, node, def, ppos, pnode, pdef) + local signdir = get_sign_dir(node, def) + local pipenumber = pdef.pipenumber + local pipedir = pnode.param2 + if string.find(pnode.name, "straight_pipe") then + if (signdir["N"] or signdir["S"]) and sphns[pipedir] then + return true + elseif (signdir["E"] or signdir["W"]) and sphew[pipedir] then + return true + end + elseif signdir["N"] and horiz_n[pipenumber] and horiz_n[pipenumber][pipedir] then + return true + elseif signdir["E"] and horiz_e[pipenumber] and horiz_e[pipenumber][pipedir] then + return true + elseif signdir["S"] and horiz_s[pipenumber] and horiz_s[pipenumber][pipedir] then + return true + elseif signdir["W"] and horiz_w[pipenumber] and horiz_w[pipenumber][pipedir] then + return true + end +end + +-- tubes + +function pipeworks.check_for_vert_tube(pos, node, def, ppos, pnode, pdef) + local signdir = get_sign_dir(node, def) + local tubenumber = pdef.tubenumber + local tubedir = pnode.param2 + if pnode.name == "pipeworks:one_way_tube" and owtv[tubedir] then + return true + elseif tubenumber == 2 and (tubedir == 5 or tubedir == 7) then -- it's a stub pointing up or down + return true + elseif signdir["N"] and vert_n[tubenumber] and vert_n[tubenumber][tubedir] then + return true + elseif signdir["E"] and vert_e[tubenumber] and vert_e[tubenumber][tubedir] then + return true + elseif signdir["S"] and vert_s[tubenumber] and vert_s[tubenumber][tubedir] then + return true + elseif signdir["W"] and vert_w[tubenumber] and vert_w[tubenumber][tubedir] then + return true + end +end + +function pipeworks.check_for_horiz_tube(pos, node, def, ppos, pnode, pdef) + local signdir = get_sign_dir(node, def) + local tubenumber = pdef.tubenumber + local tubedir = pnode.param2 + if tubenumber == 2 then -- it'a a stub pointing sideways + if (tubedir == 0 or tubedir == 2) and (signdir["N"] or signdir["S"]) then + return true + elseif (tubedir == 1 or tubedir == 3) and (signdir["E"] or signdir["W"]) then + return true + end + elseif pnode.name == "pipeworks:one_way_tube" then + if (signdir["N"] or signdir["S"]) and owtns[tubedir] then + return true + elseif (signdir["E"] or signdir["W"]) and owtew[tubedir] then + return true + end + elseif signdir["N"] and horiz_n[tubenumber] and horiz_n[tubenumber][tubedir] then + return true + elseif signdir["E"] and horiz_e[tubenumber] and horiz_e[tubenumber][tubedir] then + return true + elseif signdir["S"] and horiz_s[tubenumber] and horiz_s[tubenumber][tubedir] then + return true + elseif signdir["W"] and horiz_w[tubenumber] and horiz_w[tubenumber][tubedir] then + return true + end +end diff --git a/tube_registration.lua b/tube_registration.lua index 7bef10e..e92e676 100644 --- a/tube_registration.lua +++ b/tube_registration.lua @@ -116,7 +116,10 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e end minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"}) pipeworks.scan_for_tube_objects(pos) - end + end, + check_for_pole = pipeworks.check_for_vert_tube, + check_for_horiz_pole = pipeworks.check_for_horiz_tube, + tubenumber = tonumber(tname) } if style == "6d" then nodedef.paramtype2 = "facedir"