biogasmachines: fix crash when digging a machine.

Apparently in recent versions of TechPack API after_dig_node() method
has been functionally replaced by on_dig_node(), so all Biogas Machines
caused server to crash during removal. This commit fixes that problem.

Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
This commit is contained in:
Michal Cieslakiewicz 2020-09-24 10:47:48 +02:00
parent 2d488aaa21
commit bc8f65b29e
5 changed files with 49 additions and 89 deletions

View File

@ -350,11 +350,6 @@ local function can_dig(pos, player)
and inv:is_empty("fuel") and inv:is_empty("ice")
end
-- cleanup after digging
local function after_dig_node(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end
-- init machine after placement
local function after_place_node(pos, placer, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
@ -629,13 +624,12 @@ minetest.register_node("biogasmachines:compactor", {
groups = { choppy = 2, cracky = 2, crumbly = 2 },
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
drop = "",
can_dig = can_dig,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
machine:after_dig_node(pos, oldnode, oldmetadata, digger)
after_dig_node(pos, oldnode, oldmetadata, digger)
on_dig = function(pos, node, player)
machine:on_dig_node(pos, node, player)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,
@ -687,15 +681,8 @@ minetest.register_node("biogasmachines:compactor_active", {
groups = { crumbly = 0, not_in_creative_inventory = 1 },
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
drop = "",
can_dig = can_dig,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
machine:after_dig_node(pos, oldnode, oldmetadata, digger)
after_dig_node(pos, oldnode, oldmetadata, digger)
end,
on_rotate = screwdriver.disallow,
on_timer = on_timer,
on_receive_fields = on_receive_fields,
@ -735,9 +722,12 @@ minetest.register_node("biogasmachines:compactor_defect", {
groups = { choppy = 2, cracky = 2, crumbly = 2, not_in_creative_inventory = 1 },
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
can_dig = can_dig,
after_dig_node = after_dig_node,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,

View File

@ -170,6 +170,13 @@ end
-------
]]--
local function pipeworks_scan_for_pipe(pos)
end
if minetest.global_exists("pipeworks") then
pipeworks_scan_for_pipe = pipeworks.scan_for_pipe_objects
end
-- get bucket with water (itemstack)
local function get_water_bucket(inv, listname)
local stack = ItemStack({})
@ -285,14 +292,6 @@ local function can_dig(pos, player)
and inv:is_empty("fuel")
end
-- cleanup after digging
local function after_dig_node(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
if minetest.global_exists("pipeworks") then
pipeworks.scan_for_pipe_objects(pos)
end
end
-- init machine after placement
local function after_place_node(pos, placer, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
@ -532,9 +531,10 @@ minetest.register_node("biogasmachines:freezer", {
drop = "",
can_dig = can_dig,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
machine:after_dig_node(pos, oldnode, oldmetadata, digger)
after_dig_node(pos, oldnode, oldmetadata, digger)
on_dig = function(pos, node, player)
machine:on_dig_node(pos, node, player)
tubelib.remove_node(pos)
pipeworks_scan_for_pipe(pos)
end,
on_rotate = screwdriver.disallow,
@ -598,12 +598,6 @@ minetest.register_node("biogasmachines:freezer_active", {
drop = "",
can_dig = can_dig,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
machine:after_dig_node(pos, oldnode, oldmetadata, digger)
after_dig_node(pos, oldnode, oldmetadata, digger)
end,
on_rotate = screwdriver.disallow,
on_timer = on_timer,
on_receive_fields = on_receive_fields,
@ -654,7 +648,12 @@ minetest.register_node("biogasmachines:freezer_defect", {
right = 1 },
can_dig = can_dig,
after_dig_node = after_dig_node,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
pipeworks_scan_for_pipe(pos)
end,
on_rotate = screwdriver.disallow,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,

View File

@ -287,11 +287,6 @@ local function can_dig(pos, player)
and inv:is_empty("fuel")
end
-- cleanup after digging
local function after_dig_node(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end
-- init machine after placement
local function after_place_node(pos, placer, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
@ -516,13 +511,12 @@ minetest.register_node("biogasmachines:gasfurnace", {
groups = { choppy = 2, cracky = 2, crumbly = 2 },
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
drop = "",
can_dig = can_dig,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
machine:after_dig_node(pos, oldnode, oldmetadata, digger)
after_dig_node(pos, oldnode, oldmetadata, digger)
on_dig = function(pos, node, player)
machine:on_dig_node(pos, node, player)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,
@ -563,15 +557,8 @@ minetest.register_node("biogasmachines:gasfurnace_active", {
is_ground_content = false,
light_source = 6,
sounds = default.node_sound_metal_defaults(),
drop = "",
can_dig = can_dig,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
machine:after_dig_node(pos, oldnode, oldmetadata, digger)
after_dig_node(pos, oldnode, oldmetadata, digger)
end,
on_rotate = screwdriver.disallow,
on_timer = on_timer,
on_receive_fields = on_receive_fields,
@ -599,9 +586,12 @@ minetest.register_node("biogasmachines:gasfurnace_defect", {
groups = { choppy = 2, cracky = 2, crumbly = 2, not_in_creative_inventory = 1 },
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
can_dig = can_dig,
after_dig_node = after_dig_node,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,

View File

@ -330,11 +330,6 @@ local function can_dig(pos, player)
return inv:is_empty("src") and inv:is_empty("dst")
end
-- cleanup after digging
local function after_dig_node(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end
-- init machine after placement
local function after_place_node(pos, placer, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
@ -545,13 +540,12 @@ minetest.register_node("biogasmachines:gasifier", {
groups = { choppy = 2, cracky = 2, crumbly = 2 },
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
drop = "",
can_dig = can_dig,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
machine:after_dig_node(pos, oldnode, oldmetadata, digger)
after_dig_node(pos, oldnode, oldmetadata, digger)
on_dig = function(pos, node, player)
machine:on_dig_node(pos, node, player)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,
@ -604,15 +598,8 @@ minetest.register_node("biogasmachines:gasifier_active", {
is_ground_content = false,
light_source = 5,
sounds = default.node_sound_metal_defaults(),
drop = "",
can_dig = can_dig,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
machine:after_dig_node(pos, oldnode, oldmetadata, digger)
after_dig_node(pos, oldnode, oldmetadata, digger)
end,
on_rotate = screwdriver.disallow,
on_timer = on_timer,
on_receive_fields = on_receive_fields,
@ -651,9 +638,12 @@ minetest.register_node("biogasmachines:gasifier_defect", {
groups = { choppy = 2, cracky = 2, crumbly = 2, not_in_creative_inventory = 1 },
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
can_dig = can_dig,
after_dig_node = after_dig_node,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,

View File

@ -275,11 +275,6 @@ local function can_dig(pos, player)
and inv:is_empty("fuel")
end
-- cleanup after digging
local function after_dig_node(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end
-- init machine after placement
local function after_place_node(pos, placer, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
@ -506,13 +501,12 @@ minetest.register_node("biogasmachines:jetfurnace", {
groups = { choppy = 2, cracky = 2, crumbly = 2 },
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
drop = "",
can_dig = can_dig,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
machine:after_dig_node(pos, oldnode, oldmetadata, digger)
after_dig_node(pos, oldnode, oldmetadata, digger)
on_dig = function(pos, node, player)
machine:on_dig_node(pos, node, player)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,
@ -556,12 +550,6 @@ minetest.register_node("biogasmachines:jetfurnace_active", {
drop = "",
can_dig = can_dig,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
machine:after_dig_node(pos, oldnode, oldmetadata, digger)
after_dig_node(pos, oldnode, oldmetadata, digger)
end,
on_rotate = screwdriver.disallow,
on_timer = on_timer,
on_receive_fields = on_receive_fields,
@ -589,9 +577,12 @@ minetest.register_node("biogasmachines:jetfurnace_defect", {
groups = { choppy = 2, cracky = 2, crumbly = 2, not_in_creative_inventory = 1 },
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
can_dig = can_dig,
after_dig_node = after_dig_node,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,