Updates to digging overrides.
This commit is contained in:
parent
38567b9318
commit
bba9642e3e
@ -5,7 +5,7 @@ function quarry.override_with(node_name)
|
||||
minetest.override_item(node_name, {
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
minetest.set_node(pos, {name="default:cobble"})
|
||||
minetest.check_single_for_falling(pos)
|
||||
minetest.check_for_falling(pos)
|
||||
end
|
||||
})
|
||||
end
|
||||
@ -28,19 +28,25 @@ end
|
||||
-- Node needs two faces to air to be able to quarry.
|
||||
function quarry.valid_quarry_config(pos)
|
||||
local sum = 0
|
||||
if minetest.get_node(vector.add(pos, {x=1,y=0,z=0})).name == "air" then sum = sum + 1 end
|
||||
if minetest.get_node(vector.add(pos, {x=0,y=1,z=0})).name == "air" then sum = sum + 1 end
|
||||
if minetest.get_node(vector.add(pos, {x=0,y=0,z=1})).name == "air" then sum = sum + 1 end
|
||||
if minetest.get_node(vector.add(pos, {x=-1,y=0,z=0})).name == "air" then sum = sum + 1 end
|
||||
if minetest.get_node(vector.add(pos, {x=0,y=-1,z=0})).name == "air" then sum = sum + 1 end
|
||||
if minetest.get_node(vector.add(pos, {x=0,y=0,z=-1})).name == "air" then sum = sum + 1 end
|
||||
local fname = minetest.get_node(vector.add(pos, {x=1,y=0,z=0})).name
|
||||
if fname == "air" or minetest.get_item_group(fname, "water") > 0 then sum = sum + 1 end
|
||||
fname = minetest.get_node(vector.add(pos, {x=0,y=1,z=0})).name
|
||||
if fname == "air" or minetest.get_item_group(fname, "water") > 0 then sum = sum + 1 end
|
||||
fname = minetest.get_node(vector.add(pos, {x=0,y=0,z=1})).name
|
||||
if fname == "air" or minetest.get_item_group(fname, "water") > 0 then sum = sum + 1 end
|
||||
fname = minetest.get_node(vector.add(pos, {x=-1,y=0,z=0})).name
|
||||
if fname == "air" or minetest.get_item_group(fname, "water") > 0 then sum = sum + 1 end
|
||||
fname = minetest.get_node(vector.add(pos, {x=0,y=-1,z=0})).name
|
||||
if fname == "air" or minetest.get_item_group(fname, "water") > 0 then sum = sum + 1 end
|
||||
fname = minetest.get_node(vector.add(pos, {x=0,y=0,z=-1})).name
|
||||
if fname == "air" or minetest.get_item_group(fname, "water") > 0 then sum = sum + 1 end
|
||||
return sum >= 2
|
||||
end
|
||||
|
||||
-- For nodes that can be mortared (e.g., cobble, cut_stone, cut_stone_block).
|
||||
function quarry.mortar_on_dig(dest_name, group_wear)
|
||||
return function(pos, node, digger)
|
||||
if not minetest.is_protected(pos, digger) then
|
||||
if digger ~= nil and not minetest.is_protected(pos, digger) then
|
||||
local tool = digger:get_wielded_item():get_name()
|
||||
if tool == "quarry:trowel_and_mortar" then
|
||||
local oldnode = minetest.get_node(pos)
|
||||
@ -63,11 +69,11 @@ end
|
||||
-- For nodes that can only be pickaxed (e.g., stonebrick)
|
||||
function quarry.pick_on_dig(dest_name, group_wear)
|
||||
return function(pos, node, digger)
|
||||
if not minetest.is_protected(pos, digger) then
|
||||
if digger ~= nil and not minetest.is_protected(pos, digger) then
|
||||
local oldnode = minetest.get_node(pos)
|
||||
minetest.swap_node(pos, {name = dest_name, param2 = oldnode.param2})
|
||||
quarry.add_wear(pos, digger, group_wear)
|
||||
minetest.check_single_for_falling(pos)
|
||||
minetest.check_for_falling(pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -81,7 +87,7 @@ end
|
||||
-- For nodes that can be quarry hammered or pickaxed (e.g., stone, stone_block)
|
||||
function quarry.hammer_on_dig(dest_name, break_name, group_wear)
|
||||
return function(pos, node, digger)
|
||||
if not minetest.is_protected(pos, digger) then
|
||||
if digger ~= nil and not minetest.is_protected(pos, digger) then
|
||||
local tool = digger:get_wielded_item():get_name()
|
||||
local oldnode = minetest.get_node(pos)
|
||||
if tool == "quarry:stone_quarry_hammer" and quarry.valid_quarry_config(pos) then
|
||||
@ -90,7 +96,7 @@ function quarry.hammer_on_dig(dest_name, break_name, group_wear)
|
||||
minetest.swap_node(pos, {name = break_name, param2 = oldnode.param2})
|
||||
end
|
||||
quarry.add_wear(pos, digger, group_wear)
|
||||
minetest.check_single_for_falling(pos)
|
||||
minetest.check_for_falling(pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user