Switch from on_dig to on_destruct
This commit is contained in:
parent
72457e934c
commit
ff464ad5f6
20
init.lua
20
init.lua
@ -222,8 +222,7 @@ minetest.register_node("edit:delete", {
|
|||||||
player_data[player].delete_node1_pos = pos
|
player_data[player].delete_node1_pos = pos
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_dig = function(pos, node, digger)
|
on_destruct = function(pos)
|
||||||
minetest.remove_node(pos)
|
|
||||||
for player, data in pairs(player_data) do
|
for player, data in pairs(player_data) do
|
||||||
if
|
if
|
||||||
data.delete_node1_pos and
|
data.delete_node1_pos and
|
||||||
@ -292,8 +291,7 @@ minetest.register_node("edit:copy",{
|
|||||||
player_data[player].copy_node1_pos = pos
|
player_data[player].copy_node1_pos = pos
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_dig = function(pos, node, digger)
|
on_destruct = function(pos)
|
||||||
minetest.remove_node(pos)
|
|
||||||
for player, data in pairs(player_data) do
|
for player, data in pairs(player_data) do
|
||||||
if
|
if
|
||||||
data.copy_node1_pos and
|
data.copy_node1_pos and
|
||||||
@ -482,8 +480,7 @@ minetest.register_node("edit:fill",{
|
|||||||
player_data[player].fill1_pos = pos
|
player_data[player].fill1_pos = pos
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_dig = function(pos, node, digger)
|
on_destruct = function(pos)
|
||||||
minetest.remove_node(pos)
|
|
||||||
for player, data in pairs(player_data) do
|
for player, data in pairs(player_data) do
|
||||||
local p1 = data.fill1_pos
|
local p1 = data.fill1_pos
|
||||||
local p2 = data.fill2_pos
|
local p2 = data.fill2_pos
|
||||||
@ -532,10 +529,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
if key == "" then item = "air" end
|
if key == "" then item = "air" end
|
||||||
|
|
||||||
name = key
|
name = key
|
||||||
def = minetest.registered_nodes[name] or
|
def = minetest.registered_items[name]
|
||||||
minetest.registered_craftitems[name] or
|
|
||||||
minetest.registered_tools[name] or
|
|
||||||
minetest.registered_items[name]
|
|
||||||
|
|
||||||
if def then break end
|
if def then break end
|
||||||
end
|
end
|
||||||
@ -550,7 +544,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
elseif def.paramtype2 == "wallmounted" or def.paramtype2 == "colorwallmounted" then
|
elseif def.paramtype2 == "wallmounted" or def.paramtype2 == "colorwallmounted" then
|
||||||
param2 = minetest.dir_to_wallmounted(player:get_look_dir(), true)
|
param2 = minetest.dir_to_wallmounted(player:get_look_dir(), true)
|
||||||
end
|
end
|
||||||
|
|
||||||
local on_place = def.on_place
|
local on_place = def.on_place
|
||||||
|
|
||||||
local start = vector.new(
|
local start = vector.new(
|
||||||
@ -593,16 +587,18 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
for y = start.y, _end.y, 1 do
|
for y = start.y, _end.y, 1 do
|
||||||
for z = start.z, _end.z, 1 do
|
for z = start.z, _end.z, 1 do
|
||||||
local pos = vector.new(x, y, z)
|
local pos = vector.new(x, y, z)
|
||||||
|
|
||||||
if is_node then
|
if is_node then
|
||||||
minetest.set_node(pos, {name = name, param2 = param2})
|
minetest.set_node(pos, {name = name, param2 = param2})
|
||||||
else
|
else
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
if on_place then
|
if on_place then
|
||||||
local itemstack = ItemStack(name)
|
local itemstack = ItemStack(name)
|
||||||
pointed_thing.intersection_point = vector.new(x + 0.5, y, z + 0.5)
|
pointed_thing.intersection_point = vector.new(x + 0.5, y, z + 0.5)
|
||||||
pointed_thing.above = pos
|
pointed_thing.above = pos
|
||||||
pointed_thing.below = vector.new(x, y - 1, z)
|
pointed_thing.under = vector.new(x, y - 1, z)
|
||||||
on_place(itemstack, player, pointed_thing)
|
on_place(itemstack, player, pointed_thing)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user