forked from minetest-mods/technic
Add drop to templates
This commit is contained in:
parent
3cf0d331f0
commit
48d571bd90
|
@ -343,9 +343,29 @@ local function expand_template(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function template_drops(pos, node, oldmeta, digger)
|
||||||
|
local c = oldmeta.fields.connected
|
||||||
|
local drops
|
||||||
|
if c == "" or c == nil then
|
||||||
|
drops = {"technic:template 1"}
|
||||||
|
else
|
||||||
|
local stack_max = 99
|
||||||
|
local num = #(minetest.deserialize(c))
|
||||||
|
drops = {}
|
||||||
|
while num > stack_max do
|
||||||
|
drops[#drops+1] = "technic:template "..stack_max
|
||||||
|
num = num - stack_max
|
||||||
|
end
|
||||||
|
drops[#drops+1] = "technic:template "..num
|
||||||
|
end
|
||||||
|
print(dump(drops))
|
||||||
|
minetest.handle_node_drops(pos, drops, digger)
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("technic:template",{
|
minetest.register_node("technic:template",{
|
||||||
description = "Template",
|
description = "Template",
|
||||||
tiles = {"technic_mv_cable.png"},
|
tiles = {"technic_mv_cable.png"},
|
||||||
|
drop = "",
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||||
on_destruct = function(pos, node)
|
on_destruct = function(pos, node)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
@ -355,6 +375,7 @@ minetest.register_node("technic:template",{
|
||||||
minetest.after(0, restore_node, pos, nnode)
|
minetest.after(0, restore_node, pos, nnode)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
after_dig_node = template_drops,
|
||||||
on_punch = function(pos,node,puncher)
|
on_punch = function(pos,node,puncher)
|
||||||
hacky_swap_node(pos, "technic:template_disabled")
|
hacky_swap_node(pos, "technic:template_disabled")
|
||||||
end
|
end
|
||||||
|
@ -363,6 +384,7 @@ minetest.register_node("technic:template",{
|
||||||
minetest.register_node("technic:template_disabled",{
|
minetest.register_node("technic:template_disabled",{
|
||||||
description = "Template",
|
description = "Template",
|
||||||
tiles = {"technic_hv_cable.png"},
|
tiles = {"technic_hv_cable.png"},
|
||||||
|
drop = "",
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||||
on_destruct = function(pos, node)
|
on_destruct = function(pos, node)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
@ -372,6 +394,7 @@ minetest.register_node("technic:template_disabled",{
|
||||||
minetest.after(0, restore_node, pos, nnode)
|
minetest.after(0, restore_node, pos, nnode)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
after_dig_node = template_drops,
|
||||||
on_punch = function(pos,node,puncher)
|
on_punch = function(pos,node,puncher)
|
||||||
hacky_swap_node(pos, "technic:template")
|
hacky_swap_node(pos, "technic:template")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user