Fix cable plate placement (#446)

Cable plate placement now uses minetest.item_place
This commit is contained in:
12Me21 2018-11-23 14:25:32 -05:00 committed by SmallJoker
parent 3d52b679b0
commit 8409be32fc
1 changed files with 17 additions and 5 deletions

View File

@ -117,6 +117,19 @@ local function clear_networks(pos)
end
end
local function item_place_override_node(itemstack, placer, pointed, node)
-- Call the default on_place function with a fake itemstack
local temp_itemstack = ItemStack(itemstack)
temp_itemstack:set_name(node.name)
local original_count = temp_itemstack:get_count()
temp_itemstack =
minetest.item_place(temp_itemstack, placer, pointed, node.param2) or
temp_itemstack
-- Remove the same number of items from the real itemstack
itemstack:take_item(original_count - temp_itemstack:get_count())
return itemstack
end
function technic.register_cable(tier, size)
local ltier = string.lower(tier)
cable_tier["technic:"..ltier.."_cable"] = tier
@ -228,11 +241,10 @@ function technic.register_cable(tier, size)
num = xyz[((fine_pointed[bigger] < 0 and "-") or "") .. bigger]
end
end
minetest.set_node(pointed_thing.above, {name = "technic:"..ltier.."_cable_plate_"..num})
if not (creative and creative.is_enabled_for(placer)) then
itemstack:take_item()
end
return itemstack
return item_place_override_node(
itemstack, placer, pointed_thing,
{name = "technic:"..ltier.."_cable_plate_"..num}
)
end
else
def.groups.not_in_creative_inventory = 1