mark_diggable needed a player reference to dig steel doors without crashing

This commit is contained in:
FaceDeer 2017-10-15 12:54:48 -06:00
parent fec29263b0
commit d480b9bf2f
3 changed files with 17 additions and 17 deletions

@ -106,7 +106,7 @@ minetest.register_node("digtron:digger", {
},
-- returns fuel_cost, item_produced
execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig)
execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig, player)
local facing = minetest.get_node(pos).param2
local digpos = digtron.find_new_pos(pos, facing)
@ -114,7 +114,7 @@ minetest.register_node("digtron:digger", {
return 0, {}
end
return digtron.mark_diggable(digpos, nodes_dug)
return digtron.mark_diggable(digpos, nodes_dug, player)
end,
damage_creatures = function(player, pos, controlling_coordinate)
@ -164,7 +164,7 @@ minetest.register_node("digtron:intermittent_digger", {
on_receive_fields = intermittent_on_receive_fields,
-- returns fuel_cost, item_produced
execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig)
execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig, player)
if lateral_dig == true then
return 0, {}
end
@ -181,7 +181,7 @@ minetest.register_node("digtron:intermittent_digger", {
return 0, {}
end
return digtron.mark_diggable(digpos, nodes_dug)
return digtron.mark_diggable(digpos, nodes_dug, player)
end,
damage_creatures = function(player, pos, controlling_coordinate)
@ -229,7 +229,7 @@ minetest.register_node("digtron:soft_digger", {
"digtron_plate.png^digtron_motor.png^[colorize:" .. digtron.soft_digger_colorize,
},
execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig)
execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig, player)
local facing = minetest.get_node(pos).param2
local digpos = digtron.find_new_pos(pos, facing)
@ -238,7 +238,7 @@ minetest.register_node("digtron:soft_digger", {
end
if digtron.is_soft_material(digpos) then
return digtron.mark_diggable(digpos, nodes_dug)
return digtron.mark_diggable(digpos, nodes_dug, player)
end
return 0, {}
@ -289,7 +289,7 @@ minetest.register_node("digtron:intermittent_soft_digger", {
on_receive_fields = intermittent_on_receive_fields,
execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig)
execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig, player)
if lateral_dig == true then
return 0, {}
end
@ -307,7 +307,7 @@ minetest.register_node("digtron:intermittent_soft_digger", {
end
if digtron.is_soft_material(digpos) then
return digtron.mark_diggable(digpos, nodes_dug)
return digtron.mark_diggable(digpos, nodes_dug, player)
end
return 0, {}
@ -367,7 +367,7 @@ minetest.register_node("digtron:dual_digger", {
},
-- returns fuel_cost, items_produced
execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig)
execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig, player)
local facing = minetest.get_node(pos).param2
local digpos = digtron.find_new_pos(pos, facing)
local digdown = digtron.find_new_pos_downward(pos, facing)
@ -376,14 +376,14 @@ minetest.register_node("digtron:dual_digger", {
local cost = 0
if protected_nodes:get(digpos.x, digpos.y, digpos.z) ~= true then
local forward_cost, forward_items = digtron.mark_diggable(digpos, nodes_dug)
local forward_cost, forward_items = digtron.mark_diggable(digpos, nodes_dug, player)
for _, item in pairs(forward_items) do
table.insert(items, item)
end
cost = cost + forward_cost
end
if protected_nodes:get(digdown.x, digdown.y, digdown.z) ~= true then
local down_cost, down_items = digtron.mark_diggable(digdown, nodes_dug)
local down_cost, down_items = digtron.mark_diggable(digdown, nodes_dug, player)
for _, item in pairs(down_items) do
table.insert(items, item)
end
@ -444,7 +444,7 @@ minetest.register_node("digtron:dual_soft_digger", {
},
-- returns fuel_cost, items_produced
execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig)
execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig, player)
local facing = minetest.get_node(pos).param2
local digpos = digtron.find_new_pos(pos, facing)
local digdown = digtron.find_new_pos_downward(pos, facing)
@ -453,14 +453,14 @@ minetest.register_node("digtron:dual_soft_digger", {
local cost = 0
if protected_nodes:get(digpos.x, digpos.y, digpos.z) ~= true and digtron.is_soft_material(digpos) then
local forward_cost, forward_items = digtron.mark_diggable(digpos, nodes_dug)
local forward_cost, forward_items = digtron.mark_diggable(digpos, nodes_dug, player)
for _, item in pairs(forward_items) do
table.insert(items, item)
end
cost = cost + forward_cost
end
if protected_nodes:get(digdown.x, digdown.y, digdown.z) ~= true and digtron.is_soft_material(digdown) then
local down_cost, down_items = digtron.mark_diggable(digdown, nodes_dug)
local down_cost, down_items = digtron.mark_diggable(digdown, nodes_dug, player)
for _, item in pairs(down_items) do
table.insert(items, item)
end

@ -31,7 +31,7 @@ digtron.find_new_pos_downward = function(pos, facing)
return vector.add(pos, digtron.facedir_to_down_dir(facing))
end
digtron.mark_diggable = function(pos, nodes_dug)
digtron.mark_diggable = function(pos, nodes_dug, player)
-- mark the node as dug, if the player provided would have been able to dig it.
-- Don't *actually* dig the node yet, though, because if we dig a node with sand over it the sand will start falling
-- and then destroy whatever node we place there subsequently (either by a builder head or by moving a digtron node)

@ -133,7 +133,7 @@ digtron.execute_dig_cycle = function(pos, clicker)
local target = minetest.get_node(location.pos)
local targetdef = minetest.registered_nodes[target.name]
if targetdef.execute_dig ~= nil then
local fuel_cost, dropped = targetdef.execute_dig(location.pos, layout.protected, layout.nodes_dug, controlling_coordinate)
local fuel_cost, dropped = targetdef.execute_dig(location.pos, layout.protected, layout.nodes_dug, controlling_coordinate, false, clicker)
if table.getn(dropped) > 0 then
for _, itemname in pairs(dropped) do
table.insert(items_dropped, itemname)
@ -449,7 +449,7 @@ digtron.execute_downward_dig_cycle = function(pos, clicker)
local target = minetest.get_node(location.pos)
local targetdef = minetest.registered_nodes[target.name]
if targetdef.execute_dig ~= nil then
local fuel_cost, dropped = targetdef.execute_dig(location.pos, layout.protected, layout.nodes_dug, controlling_coordinate, true)
local fuel_cost, dropped = targetdef.execute_dig(location.pos, layout.protected, layout.nodes_dug, controlling_coordinate, true, clicker)
if table.getn(dropped) > 0 then
for _, itemname in pairs(dropped) do
table.insert(items_dropped, itemname)